This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 4
Aug 2018

My requirement includes selecting of checkboxes for all the items. Attributes avail which are index, resource-id are static. The instance is of dynamic & increases with the items list.
ref:: 0,1,2,3 et…

How to select the checkboxes of the list in appium??

WebElement checkboxallSelection = driver.findElementByXPath("//android.widget.paths[contains 
 (@instance, '0')]");
 checkboxallSelection.click();

The above sample code is for 1 selection of checkbox. But, i need for all 0,1,2,…n?
How can I attain this??

  • created

    Aug '18
  • last reply

    Aug '18
  • 3

    replies

  • 371

    views

  • 2

    users

  • 2

    links

Selenium supports selecting multiple elements by one XPath statement… put an ‘s’ behind .findElement to get an array/list of WebElements… it would be .findElementsByXPath(…)… You can also do webElement.findElementsByXPath(…) if you want to first select the element that contains your whole list and then select the individual list items out in into an array… Once you have your list, you can iterate over it in a for loop

I have some idle time at work and reread your post… Your XPath is a little special and you may not be able to get it done with a list of elements… you could also try:

int i = 0;
while(true){
WebElement checkboxallSelection = driver.findElementByXPath("//android.widget.paths[contains(@instance, “+i+”)]");
if(checkboxallSelection == null){
break;
}
checkboxallSelection.click();
i++
}