Appium iOS automation using Java : get element using accessibility Id?

你离开我真会死。 提交于 2019-12-13 06:38:24

问题


I am new to iOS automation using Appium. I can access elements and do automation using XPath like this

driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[3]")).click();

I would like to access elements using the accessibility label name given. When using the Appium inspector I can see that the accessibility name is displayed under the parameter Value . But How to access this value using Java code?

Thanks.


回答1:


You should be able to use the findElementByAccessibilityId(String using) method in Java. More info on it here:

http://appium.github.io/java-client/io/appium/java_client/FindsByAccessibilityId.html




回答2:


getAttribute will return the all the information about the element, you just need to filter what you want, Following code will return the value of the element.

driver.findElement(By.name("Sign in")).getAttribute("value")



来源:https://stackoverflow.com/questions/30760384/appium-ios-automation-using-java-get-element-using-accessibility-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!