Reputation: 51
I am using Selenium 3.x with Appium and working on Native iOS App which uses XCUITest as Automation name.
I can access individual element with Accessibility ID and it works fine e.g. driver.findElement(MobileBy.AccessibilityId("Location")).click();
Is there way to get a list of all Accessiblilty IDs (or the values) on a single page / form?
Thanks in advance.
Upvotes: 0
Views: 1442
Reputation: 3384
You can try something like below, only you have tochange first line of the code as per android schema, as I'm not aware where all the elements are contained in an app.
Following example identifies the name (or accessibility id attribute in your case) for all the div elements, so you just need to tweak the first line:
List<WebElement> allElems = driver.findElements(By.xpath("//body//div"));
System.out.println("Avaialable Accesible ids :");
int c=0;
for(WebElement ele : allElems) {
c++;
System.out.print("for element " + c +" Accessibility ID is :");
System.out.println(ele.getAttribute("name"));
//or
System.out.println(ele.getAttribute("content-desc"));
}
Upvotes: 0