Web tables or data tables are often used in scenarios where you need to display the information in a tabular format. The data being displayed can either be static or dynamic. You’d often see such examples in e-commerce portals, where product specifications are displayed in a web table. With its wide use, you’d often come across scenarios where you’ll need to handle them in your Selenium test automation scripts.

In this Selenium WebDriver tutorial, I’ll take a look at how to handle a web table in Selenium along with a few useful operations that can be performed on web tables. By the end of this tutorial, you’ll gain a thorough understanding of web tables in Selenium test automation along with methodologies used to access content in the web table.

What Is a Web Table in Selenium?

Web table in Selenium is a WebElement just like any other popular WebElements like text boxes, radio buttons, checkboxes, drop-down menus, etc. Web table and its contents can be accessed by using the WebElement functions along with locators to identify the element (row/column) on which the operation needs to be performed.

A table consists of rows and columns. The table created for a web page is called a web table. Below are some of the important tags associated with a web table:

  • < table > – Defines an HTML table
  • < th > – Contains header information in a table
  • < tr > – Defines a row in a table
  • < td > – Defines a column in a table

Types of Web Tables in Selenium

There are two broad categories of tables namely:

Static Web Table

As the name indicates, the information in the table is static.

Dynamic Web Table

The information displayed in the table is dynamic. E.g. Detailed Product information on e-commerce websites, sales reports, etc.

For the demonstration to handle the table in Selenium, we make use of a table that is available in the w3school HTML table page. Though there are fewer cross-browser testing issues when using tables, some of the old browser versions of Internet Explorer, Chrome, and other web browsers don’t support HTML Table APIs.

Now that we’ve covered the basics, next in this Selenium WebDriver tutorial, I’ll take a look at some of the frequently used operations to handle tables in Selenium that would help in your Selenium test automation efforts.

Handling Web Tables in Selenium

I’ll use the local Selenium WebDriver for performing browser actions to handle tables in Selenium, present on w3schools HTML table page. The HTML code for the web table used for demonstration is available on the tryit adapter page.

web tables

#selenium #java #web-development #developer

How To Handle Web Table in Selenium WebDriver?
2.05 GEEK