I have a xpath expression:
referenceIn3DPage=Driver.driver.findElement(By.xpath("//div[3][@class='some-class']/div[1]//label")).getAttribute("id");
I want to loop from 1
to 9
for div[]
.
Below is my code to loop div[i]
from 1 to 9
:
String referenceIn3DPage =null;
int count=Driver.driver.findElements(By.xpath("//div[3][@class='some-class']//input")).size();
System.out.println("the count="+count);
for(int i=1;i<=count;i++)
{
referenceIn3DPage=Driver.driver.findElement(By.xpath("//div[3][@class='some-class']/div["+i+"]//label/input")).getAttribute("id");
System.out.println("the value in 3d= "+referenceIn3DPage);
}
But, it is not working as per my requirement. I want script to display OSP102 and 8 more reference ID (please refer to link given below for list of reference IDs.)
The output:
the count=9
the value in 3d= OSCP102
NOTE: Please refers to my original question for better clarity.
How to grab text corresponding to checkboxes in selenium webdriver?