Appium appium1.0 的 find_element_by_accessibility_id 有时候无法顺利定位元素

shuiguolan · 2014年05月27日 · 最后由 青青 回复于 2015年07月23日 · 1385 次阅读

运行官方脚本时,发现脚本报错。同一个 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)
.....

共收到 4 条回复 时间 点赞

出错信息是?

升级到 appium1.1.0,这个问题没有再出现

#2 楼 @shuiguolan accessibility_id 是指的控件的哪个属性

#3 楼 @zwdlp520 同问
#2 楼 @shuiguolan IOS 里面 locator 需要的 id 是至的控件的那个属性呢?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册