I want to get the value of this aria-checked = ‘true’ as shown in the screenshot below. I am able to get this value easily by using below code:
WebElement searchTextBox= driver.findElement(By.className(“ui-igcheckbox-container”));
// retrieving html attribute value using getAttribute() method
String typeValue=searchTextBox.getAttribute(“aria-checked”);
System.out.println("Value of type attribute: "+typeValue);
But the problem here is I want to get this value Dynamically above code only returns only first value of the table row. Can anyone help me how to get this value dynamically?
In case there are multiple elements (checkboxes) matching this locator you may get all them into a list and get each element attribute iterating over that list
List<WebElement> searchTextBoxes= driver.findElements(By.className(“ui-igcheckbox-container”));
for(WebElement searchTextBox : searchTextBoxes){
String typeValue=searchTextBox.getAttribute(“aria-checked”);
System.out.println("Value of type attribute: "+typeValue);
}