简体   繁体   English

无法通过ID访问元素

[英]Could not access element by ID

I am facing with problem when I tried to access Android element by ID in C#, I also tried with Appium-desktop version and seems not accessible for example: 我在C#中尝试通过ID访问Android元素时遇到了问题,我也尝试使用Appium桌面版本,例如似乎无法访问:

I tried with and without package name and there is an exception every time which says could not find element. 我尝试使用和不使用包名称,每次都有一个异常,提示找不到元素。 Also from Appium desktop selector. 同样来自Appium桌面选择器。

AndroidElement selectPlant = driver.FindElementById("com.heidelbergcement.aom.stage.dev:id/loginForm-plantSelection")

You're misunderstanding something. 你误会了。

FindElementById refers to the unique identifier of the element which in most cases is the RuntimeId of the UI element. FindElementById引用元素的唯一标识符,该标识符在大多数情况下是UI元素的RuntimeId。

What you should use is findElementByAccessibilityId , which refers to AutomationId of the UI element as shown in the inspect tool. 您应该使用的是findElementByAccessibilityId ,它表示检查工具中所示的UI元素的AutomationId。

Total credit to this . 信贷总额

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM