Every automation tester should possess the following two skills while developing an automation test script. 1) Getting to know automation tools 2) locating web elements. As an automation testing company, we have mitigated several failed Selenium automation testing projects. Most of them failed due to not following test automation best practices, writing absolute XPaths & CSS Selectors. Learning Selenium Tool commands is easy. However, writing robust Selenium locators comes from experience. To help newbie test automation engineers, we have written this blog article with various XPath Examples for HTML Tables.
XPath to locate a table using row count
Sometimes you may need to identify an HTML table using its row count. Using XPath count function, you can find a table using row count. The below table has 6 rows including a row for headers. Let’s see how to identify using its row count.
locate using column count
Locating a table using column count is simple. Just add 'th' in the Row count Xpath.
locate Last Row
You no need to use For Loop to identify last row in a table. Use 'Last' XPath function to locate last row.
Identify Alternate Rows