android appium 测试完成后 5 gui 崩溃
android 5 gui crash after appium test finished
所以,问题是当 appium python 测试完成时 android OS 崩溃了。
似乎无法打开任何应用程序,但是,设备会在屏幕之间滑动时做出反应。
为了解决这个问题,我必须重新启动设备,一切都会恢复正常。
有趣的是,这种情况发生在大约 60% 的情况下。
我的测试结构是这样的
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class SimpleAndroidTests(unittest.TestCase):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'here_device_id
desired_caps['app'] = PATH(
'path_to_apk'
)
def setUp(self):
desired_caps = Main.desired_caps
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
self.driver.quit()
def test_add_contacts(self):
el = self.driver.find_element_by_accessibility_id("Add Contact")
el.click()
textfields = self.driver.find_elements_by_class_name("android.widget.EditText")
textfields[0].send_keys("Appium User")
textfields[2].send_keys("someone@appium.io")
self.assertEqual('Appium User', textfields[0].text)
self.assertEqual('someone@appium.io', textfields[2].text)
self.driver.find_element_by_accessibility_id("Save").click()s
alert = self.driver.switch_to_alert(
self.driver.find_element_by_android_uiautomator('new UiSelector().clickable(true)').click()
self.driver.press_keycode(3)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(SimpleAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)
该问题仅在 android 5,5+ 设备中重现。在 adroid 4.4 上一切正常。
此问题已在 Android 5.1 中修复。
所以,问题是当 appium python 测试完成时 android OS 崩溃了。 似乎无法打开任何应用程序,但是,设备会在屏幕之间滑动时做出反应。 为了解决这个问题,我必须重新启动设备,一切都会恢复正常。 有趣的是,这种情况发生在大约 60% 的情况下。
我的测试结构是这样的
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class SimpleAndroidTests(unittest.TestCase):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'here_device_id
desired_caps['app'] = PATH(
'path_to_apk'
)
def setUp(self):
desired_caps = Main.desired_caps
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
self.driver.quit()
def test_add_contacts(self):
el = self.driver.find_element_by_accessibility_id("Add Contact")
el.click()
textfields = self.driver.find_elements_by_class_name("android.widget.EditText")
textfields[0].send_keys("Appium User")
textfields[2].send_keys("someone@appium.io")
self.assertEqual('Appium User', textfields[0].text)
self.assertEqual('someone@appium.io', textfields[2].text)
self.driver.find_element_by_accessibility_id("Save").click()s
alert = self.driver.switch_to_alert(
self.driver.find_element_by_android_uiautomator('new UiSelector().clickable(true)').click()
self.driver.press_keycode(3)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(SimpleAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)
该问题仅在 android 5,5+ 设备中重现。在 adroid 4.4 上一切正常。
此问题已在 Android 5.1 中修复。