I have of items that has a check option, I need to select all the items.
The attributes available are resource-id, index which are static.
Instance which is dynamic and increases with the list of items eg: 0,1,2…

How can I select all the in the list.

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

WebElement checkboxSelection = driver.findElementByXPath("//android.widget.xxxxx[contains (@instance, '1')]");
        checkboxSelection.click();

WebElement checkboxSelection = driver.findElementByXPath("//android.widget.xxxxx[contains (@instance, '2')]");
        checkboxSelection.click();

The above code does just a single selection, since I want to select also 1,2,…n how could I achieve this?

I tried something like this and this doesn’t result in locating the element

for (int j=0;j<=10;j++){
            WebElement contactSelection = driver.findElementByXPath("//android.widget.CheckBox"+j+"instance");
            contactSelection.click();
        }



Source link https://sqa.stackexchange.com/questions/35101/--checkboxes-in-list--in-

LEAVE A REPLY

Please enter your comment!
Please enter your name here