Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

循环点击一个元素,当元素消失时报错TypeError: object of type 'NoneType' has no len() #592

Open
1 task done
songzhenhua opened this issue Aug 31, 2023 · 0 comments

Comments

@songzhenhua
Copy link

💡相关项目: Poco

标题: [BUG提交]循环点击一个元素,当元素消失时报错TypeError: object of type 'NoneType' has no len()

AirtestIDE版本:

  • 使用了本地Pyhton环境运行脚本
  • Python版本: 3.8
  • Airtest版本: v1.3.0

报错描述:
    poco从1.0.85升到1.0.89,发现个问题,同样的脚本,场景如下:
一个场景有2个按钮,定义好后,点一下A,再点一下B,循环点,比如点3下A就消失了,此时A.wait()会报错

  File "/Users/szh/opt/miniconda3/envs/test/lib/python3.8/site-packages/poco/proxy.py", line 272, in __len__
    return len(nodes)
TypeError: object of type 'NoneType' has no len()

根据报错内容看到272行是return len(nodes),也就是nodes可能是None。进入到nodes的求值方法_do_query(),发现与1.0.85不一样的地方就是多了一行self.invalidate(),怀疑是1.0.87添加refresh()功能引起的。

暂时修改/poco/proxy.py中__len__()方法,在272行返回前添加非None判断

if nodes is None:
    nodes = []

之后正常

相关截图:

报错Log:

  File "/Users/szh/opt/miniconda3/envs/test/lib/python3.8/site-packages/poco/proxy.py", line 272, in __len__
    return len(nodes)
TypeError: object of type 'NoneType' has no len()

连接设备信息:

设备类型 设备型号 系统版本号 apk名称/下载链接
Android

提供最小可复现此BUG的代码:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant