Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to find specific lines in a table using Selenium?
We can find specific lines in a table with Selenium webdriver. A table is identified in an html document with
| tag to represent columns. To traverse through table rows and columns we use the method findElements(). To count the total number of rows in table we use size() method available for list − List To count the total number of columns in table we use size() method available for list − List Let us consider the below table and get the value of TYPE having AUTOMATION TOOL as UFT.
The html structure of a table is described below −
ExampleCode Implementation. import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class TableHandling{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = " https://sqengineer.com/practice-sites/practice-tables- selenium/";
driver.get(url);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
// identify table
WebElement mytable = driver.findElement(By.xpath("//table[@id='table1']/tbody"));
//identify rows of table.
List
|
Advertisements



