Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
10いいね 270 views回再生

How to handle WebTables using Selenium WebDriver || Part-1 || Selenium Automation

In this session you will learn what is Web Table and how to test Web Tables and how to handle Web Tables during your test

*******************************************************************
You can get complete programs from below GitHub Repository
*******************************************************************
https://github.com/knowledgeshare-tec...


*******************************************************************
You can see step by step selenium sessions from below playlist
*******************************************************************
   • How to Upload a File using Selenium WebDri...  

***********************************************
For regular updates you can join this Group
***********************************************
  / 4754296501308288  

****************************************************
Overview on Web Table
****************************************************

What is Web Table

Web Tables are Data Tables used to display Data in Tabular Format
Web Table data can be Static or Dynamic

What test we perform on this Web Tables

To Read Headers of the Table
To Count Number of Rows displays to compare with Database Count
Example : To Sum up any Column
Example : To find Top 5 Companies from a table based on turnover

How to Handle Web Table

Finding the table /table header/table row/table data using XPATH
Using List#WebElement# to store the values
Finally we iterate through the values using loops / Iterator to perform validations as per requirement

*********************************************************
Example program for Handling Web Table
( Get number of rows and columns of a web table )
*********************************************************

package com.seleniumbasics;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class WebTable_Example_Count_Rows_Columns {

public static void main(String[] args)
{

System.setProperty("webdriver.chrome.driver", ".\\drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.navigate().to("http://the-internet.herokuapp.com/tables");


List col=driver.findElements(By.xpath("//*[@id=\"table1\"]/thead/tr/th"));
int no_of_columns=col.size();
System.out.println("Number of Columns in a web table : " + no_of_columns);

List rows=driver.findElements(By.xpath("//*[@id=\"table1\"]/tbody/tr"));
int no_of_rows=rows.size();
System.out.println("Number of rows/records in a webtable : " + no_of_rows);

}

}

コメント