I need to select a column value only if value of column 1 and 7 matches in a specific row of a table. the number of rows is dynamic and has 8 columns.
This is my code :
WebElement session_table = driver.findElement(By.id("sessions_table"));
List<WebElement> session_row = driver.findElements(By.tagName("tr"));
System.out.println(session_row.get(2).findElement(By.xpath("//td[2]")).getText());
Iterator<WebElement> i= session_row.iterator();
while(i.hasNext())
{
WebElement srow= i.next();
List<WebElement> session_data = srow.findElements(By.xpath("//td"));
stime = session_data.get(0).getText();
coach_name = session_data.get(6).getText();
System.out.println( stime + " " + coach_name);
if((stime == "11/02/12 07:30 AM") && (coach_name == "Test Coach1") )
{
driver.findElement(By.xpath("(//a[contains(text(),'0/4')])")).click();
}
}
But the variables stime and coach_name are assigned the value of first row. it does not change with iteration. For example if first row has value " 07:00 AM " and coach name Test and there are 80 rows, it prints "07:00 AM Test" 80 times. but i need to read value of each row. Note : i use selenium webdriver with java