I want to test a data in html table.and verify it with database which contains the staff information. Below is the code. now i am stuck for creating assert, how to collect the rows or list of list of the table values
@Test
public static void login()
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "E:\\Amol\\Tfleet-Activities\\automation\\tfleet\\chromedriver\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(300, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://ift.tt/25NyAld");
driver.findElement(By.xpath(".//*[@id='login_session']")).sendKeys("admin");
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[@id='pwd_session']")).sendKeys("admin");
driver.findElement(By.xpath(".//*[@id='login']")).click();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[@id=`enter code here`'content']/h2[2]/a")).click(); // click on admin
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='content']/h2[2]/a")).click(); // click on staff member
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
i have tried, for it ref.below code but i am not understanding how to do this.
List<WebElement> tablerow = driver.findElements(By.xpath("//table//tr"));
System.out.println(tablerow.size());
for(int i=0;i<tablerow.size();i++) {
// for(int j=5;j<=9;j++) {
List<WebElement> cells = tablerow.get(i).findElements(By.xpath("//td"));
for(int j=4;j<cells.size();j++)
{
System.out.println(cells.get(i).getText());
}
Aucun commentaire:
Enregistrer un commentaire