Skip to content

Instantly share code, notes, and snippets.

@ssmiech
Created May 24, 2013 09:29
Show Gist options
  • Save ssmiech/5642387 to your computer and use it in GitHub Desktop.
Save ssmiech/5642387 to your computer and use it in GitHub Desktop.
package selenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;;
public class test {
public static void main(String[] args) {
String text = "";
WebDriver driver = new FirefoxDriver();
// And now use this to visit your page
driver.get("http://localhost");
WebElement table = driver.findElement(By.tagName("table"));
List<WebElement> allrows = table.findElements(By.tagName("tr"));
System.out.println(allrows);
for(WebElement row : allrows){
By.tagName("td");
//Well maybe first few rows don't have a "dis_customer" column
if(row.findElements(By.className("dis_customer")).size() > 0) {
WebElement data = row.findElement(By.className("dis_customer"));
By.tagName("div");
text = data.getText();
}
}
System.out.println(text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment