运行官方脚本时,发现脚本报错。同一个 test 方法,在执行时,上一个界面的元素可以通过 find_element_by_accessibility_id 定位,但是当打开下一个界面时该方法在定位另一个元素时就出错了,这是怎么回事,哪位大侠可以解释一下,谢谢。

以下是截取的出错的官方程序:python-client / test / functional / android / touch_action_tests.py
出错的位置是
el = self.driver.find_element_by_accessibility_id('Expandable Lists')
.....
def test_long_press(self):
el1 = self.driver.find_element_by_name('Content')
el2 = self.driver.find_element_by_accessibility_id('Animation')

action = TouchAction(self.driver)
action.press(el1).move_to(el2).perform()

el = self.driver.find_element_by_accessibility_id('Views')
# self.assertIsNotNone(el)
action.tap(el).perform()

el = self.driver.find_element_by_accessibility_id('Expandable Lists')
# self.assertIsNotNone(el)
action.tap(el).perform()

el = self.driver.find_element_by_name('1. Custom Adapter')
# self.assertIsNotNone(el)
action.tap(el).perform()

el = self.driver.find_element_by_name('People Names')
# self.assertIsNotNone(el)
action.long_press(el).perform()

# 'Sample menu' only comes up with a long press, not a tap
el = self.driver.find_element_by_name('Sample menu')
self.assertIsNotNone(el)
.....


↙↙↙阅读原文可查看相关链接,并与作者交流