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

(开头的xpath识别错误 #941

Closed
zykeee opened this issue Feb 23, 2024 · 2 comments
Closed

(开头的xpath识别错误 #941

zykeee opened this issue Feb 23, 2024 · 2 comments
Assignees
Labels

Comments

@zykeee
Copy link

zykeee commented Feb 23, 2024

使用括号开头的xpath(//android.widget.ImageView)[2]用来匹配第n个match的元素时
会被当作自定义的字符串匹配语法处理

  • 手机型号:任意
  • uiautomator2的版本号:2.16.25
  • 手机截图:无
  • 相关日志:uiautomator2.exceptions.XPathElementNotFoundError: ["//*[@text='(//android.widget.ImageView)[2]' or @content-desc='(//android.widget.ImageView)[2]' or @resource-id='(//android.widget.ImageView)[2]']"]
  • 附上可能复现问题的代码:d.xpath("(//android.widget.ImageView)[2]").get(1)
@codeskyblue
Copy link
Member

前面加个/试试

@zykeee
Copy link
Author

zykeee commented Feb 27, 2024

加/会被当作Invalid expression处理

@codeskyblue codeskyblue added the bug label Apr 9, 2024
@codeskyblue codeskyblue self-assigned this Apr 9, 2024
codeskyblue added a commit that referenced this issue Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants