You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import time
from time import sleep
import logging
import uiautomator2 as u2
d = u2.connect('0123456789ABCDEF')
d.xpath("//android.widget.TextView[1][@resource-id='com.tencent.android.qqdownloader:id/wo']").click()
sleep(2)
d.press('back')
sleep(2)
for x in d.xpath("//android.widget.TextView[@resource-id='com.tencent.android.qqdownloader:id/wo']").all():
print("Text:", x.text)
# 上面的for循环可以通过text取值,为何单独时就没有text attribute呢?
result = d.xpath("//android.widget.TextView[1][@resource-id='com.tencent.android.qqdownloader:id/wo']")
print(f'result: {result.text}')
“
>>output
Text: 视频
Text: 阅读
Text: 社交
Text: 理财
Text: 购物
Traceback (most recent call last):
File "C:\Users\q\Desktop\temp.py", line 17, in <module>
print(f'result: {result.text}')
AttributeError: 'XPathSelector' object has no attribute 'text'
Versions (版本)
Version: 0.2.3.dev2
Issue and steps to reproduce (复现步骤)
上面的for循环可以通过text取值,为何单独时就没有text attribute呢?
result = d.xpath("//android.widget.TextView[1][@resource-id='com.tencent.android.qqdownloader:id/wo']")
print(f'result: {result.text}')
Screenshots (相关截图)
能有尽量有
Additional Details (其他信息)
The text was updated successfully, but these errors were encountered:
注,代码或者日志请使用Markdown语法,看完删掉
Versions (版本)
Version: 0.2.3.dev2
Issue and steps to reproduce (复现步骤)
上面的for循环可以通过text取值,为何单独时就没有text attribute呢?
result = d.xpath("//android.widget.TextView[1][@resource-id='com.tencent.android.qqdownloader:id/wo']")
print(f'result: {result.text}')
Screenshots (相关截图)
能有尽量有
Additional Details (其他信息)
The text was updated successfully, but these errors were encountered: