openatx / facebook-wda

Facebook WebDriverAgent Python Client Library (not official)
MIT License
1.72k stars 266 forks source link

获取不到通过xpath定位的元素 #103

Closed xianyiLuo closed 3 years ago

xianyiLuo commented 3 years ago

Traceback (most recent call last): File "test_case/test_ios.py", line 58, in ios.test_step2() File "test_case/test_ios.py", line 24, in test_step2 self.driver.xpath('//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[3]/Button[1]/StaticText[1]').click() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1516, in click e = self.get(timeout=timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1478, in get "timeout %.1f" % timeout) wda.exceptions.WDAElementNotFoundError: ('element not found', 'timeout 10.0')

iOS版本:13.1.3 xcode版本:11.3.1 wda:0.3.0

codeskyblue commented 3 years ago

wda的版本不太对。pip3 uninstall wda && pip3 install facebook-wda

xianyiLuo commented 3 years ago

更新facebook-wda到最新版:1.3.4 看起来是部分xpath能够获取到,部分不能 特意延长了查找元素时间也获取不到

xianyiLuo commented 3 years ago

找到原因了,xpath生成的时候如果底下只有一个节点会生成Other[1],把[1]去掉即可