AirtestProject / AirtestProject/Poco

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

Ouverte
#592 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
2k
Forks
341
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

:bulb:**相关项目:** Poco

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

**AirtestIDE版本:** 无

- [x] **使用了本地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的代码:**
```

```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.