openatx / facebook-wda

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

使用d(name='相册').wait_gone(timeout=10.0) 当目标关键词消失后报错 #100

Open huanzhijin opened 3 years ago

huanzhijin commented 3 years ago

d(name='相机').wait_gone(timeout=10.0) 报错如下 Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1480, in wait_gone if not self.exists: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1425, in exists return len(self.find_element_ids()) > self._index File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1354, in find_element_ids return self._wdasearch('class chain', chain) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1303, in _wdasearch 'value': value File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/utils.py", line 47, in _inner return fn(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 418, in _fetch response = httpdo(url, method, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 121, in httpdo return _unsafe_httpdo(url, method, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 175, in _unsafe_httpdo raise WDARequestError(status, value) wda.exceptions.WDARequestError: WDARequestError(status=110, value={'error': 'stale element reference', 'message': 'The previously found element ""相机" StaticText" is not present in the current view anymore. Make sure the application UI has the expected state. Original error: No matches found for Elements matching predicate \'wdName == "相机" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\' from input {(\n Window, {{0.0, 0.0}, {414.0, 896.0}},\n Window, {{0.0, 0.0}, {414.(SDP {{15.0, 335.5}, {360.0, 1.0}},\n StaticText, {{20.0, 293.0}, {355.0, Image, {{12.0, 114.0}, {40.0, 40.0}},\n CollectionView, {{12.0, 174.0}, {390.0, 120.0}},\n Other, {{0.0, 293.0}, {414.0, 60.0}},\n Other, {{0.0, 353.0}, {414.0, 60.0}},\n Other, {{0.0, 413.0}, {414.0, 60.0}},\n Other, {{0.0, 473.0}, {414.0, 60.0}},\n Other, {{0.0, 533.0}, {414.0, 60.0}},\n Other, {{0.0, 593.0}, {414.0, 60.0}},\n Other, {{0.0, 653.0}, {414.0, 60.0}},\n Other, {{0.0, 713.0}, {414.0, 60.0}},\n Other, {{0.0, 773.0}, {414.0, 60.0}},\n Other, {{0.0, 833.0}, {414.0, 60.0}},\n Cell, {{12.0, 174.0}, {151.0, 120.0}},\n Cell, {{173.0, 174.0}, {151.0, 120.0}},\n Cell, {{334.0, 174.0}, {151.0, 120.0}},\n Other, {{12.0, 174.0}, {151.0, 120.0}},\n Other, {{173.0, 174.0}, {151.0, 120.0}},\n Other, {{334.0, 174.0}, {151.0, 120.0}},\n Other, {{12.0, 174.0}, {151.0, 120.0}},\n Other, {{173.0, 174.0}, {151.0, 120.0}},\n Other, {{334.0, 174.0}, {151.0, 120.0}},\n Image, {{22.0, 182.0}, {23.0, 23.0}},\n Image, {{191.0, 182.0}, {23.0, 23.0}},\n Image, {{183.0, 190.5}, {6.0, 6.0}},\n Image, {{344.0, 182.0}, {23.0, 23.0}}\n)}'}) [Finished 2.186s]

codeskyblue commented 3 years ago

我看错误是:'stale element reference' 不是每次都出来吧

huanzhijin commented 3 years ago

特定页面必现

codeskyblue commented 3 years ago

那个界面方便截图看下不

huanzhijin commented 3 years ago

特定页面切换到桌面,也报错

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 1480, in wait_gone
    if not self.exists:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 1425, in exists
    return len(self.find_element_ids()) > self._index
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 1354, in find_element_ids
    return self._wdasearch('class chain', chain)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 1303, in _wdasearch
    'value': value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/utils.py", line 47, in _inner
    return fn(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 418, in _fetch
    response = httpdo(url, method, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 121, in httpdo
    return _unsafe_httpdo(url, method, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/__init__.py", line 175, in _unsafe_httpdo
    raise WDARequestError(status, value)
wda.exceptions.WDARequestError: WDARequestError(status=110, value={'error': 'stale element reference', 'message': 'The previously found element ""相机" StaticText" is not present in the current view anymore. Make sure the application UI has the expected state. Original error: Error getting main window kAXErrorServerNotFound'})
[Finished 5.018s]
huanzhijin commented 3 years ago

image

codeskyblue commented 3 years ago

我这边暂时复现不了,不过做了一下重试处理。版本1.2.2 pip3 install -U facebook-wda 升级一下就可以。 https://github.com/openatx/facebook-wda/commit/252ab24e6c74c91cb57c2b7f5891514268560229

huanzhijin commented 3 years ago

升到1.2.2后 关键词消失不报错了,但不消失却报错了 Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 1509, in wait_gone raise WDAElementNotDisappearError("element not gone") wda.exceptions.WDAElementNotDisappearError: element not gone [Finished 10.045s]