Dynamic Table:-
If a number of rows and columns not fixed then it is called a dynamic table we can also retrieve a record from Web Driver Code to dynamic Table.
Q) CREATE AUTOMATION SCRIPT to COUNT NUMBER OF ROWS and COLUMN using selenium Web Driver?
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class DynamicTableExample {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","c:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://demo.guru99.com/test/web-table-element.php");
List col = driver.findElements(By.xpath("//*[@id=\"leftcontainer\"]/table/thead/tr/th"));
List row = driver.findElements(By.xpath("//*[@id=\"leftcontainer\"]/table/tbody/tr/td[1]"));
System.out.print("number of column is "+col.size());
System.out.print("number of rows is "+row.size());
}
}
If a number of rows and columns not fixed then it is called a dynamic table we can also retrieve a record from Web Driver Code to dynamic Table.
Q) CREATE AUTOMATION SCRIPT to COUNT NUMBER OF ROWS and COLUMN using selenium Web Driver?
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class DynamicTableExample {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","c:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://demo.guru99.com/test/web-table-element.php");
List col = driver.findElements(By.xpath("//*[@id=\"leftcontainer\"]/table/thead/tr/th"));
List row = driver.findElements(By.xpath("//*[@id=\"leftcontainer\"]/table/tbody/tr/td[1]"));
System.out.print("number of column is "+col.size());
System.out.print("number of rows is "+row.size());
}
}
Post a Comment
If you have any doubt in programming or join online classes then you can contact us by comment .