There are 38 div tags in my web application and I want to get the text present in each div tags.following is the code:-
<div class="w-100 dt pa2 f7"> //this is parent div class
<div class="bg-white-10">//sub class
<div class="dib bg-dirty-green w-100">//sublcass
<p class="pa2 ma0 fl f6"> // class from where i want to capture the text
<span class="v-mid">Mega Contest - 20</span> </p> //this is the text which i want to capture.
I tried the following code: -
WebElement wb = driver.findElement(By.xpath("/html/body/div[1]/div/div/div[2]/div[3]/div[3]")); //CONTEST_TABLE
List<WebElement> list = driver.findElements(By.xpath("//*[@class='pa2 ma0 fl f6']")); //NUMBER_OF_CONTEST
int rc=list.size();
System.out.println(rc);
for(int i=0;i<rc;i++)
{
WebElement Contest_Name= list.get(i).findElement(By.xpath("//*[@class='pa2 ma0 fl f6']"));
String name = Contest_Name.getText();
System.out.println(name);
}
I am getting "Mega Contest - 20" 38 times...