Home > Automation Testing > Advance Selenium > Finding elements of table in selenium

Finding elements of table in selenium

Elements in table can be accessed using xpath.

Here is the sample HTML code:

To locate first “td” in first “tr” in above HTML code. Below is the xpath:

 

//table//tr[1]/td[1]

To locate second “td” in first “tr”. Below is the xpath.

//table//tr[1]/td[2]

To locate cells of Pune and Mumbai below is the xpath.

//table//tr[1]/td

To locate the cells of Pune, Hubli and Shirdi below is the xpath.

//table//tr/td[1]

To locate the cells of Mumbai, Bangalore and Nashik below is the xpath.

//table//tr/td[2]

To locate all 6 cells. Below is the xpath.

//table//tr/td

This Article is TAGGED in , . BOOKMARK THE permalink.

Avatar photo
Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">