Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

I am new in selenium testing. I want to get the CSS class name using selenium. I am using eclipse and Java for development.

<table >

<tr class="odd"><td>Odd row</td></tr>

<tr class="even"><td>Even row</td></tr>

<tr class="odd"><td>Odd row2</td></tr>

<tr class="even"><td>Even row2</td></tr>       


Is there any way to get the class name 'odd' or 'even' using selenium? 

1 Answer

0 votes
by (62.9k points)

You can use the getAttribute(attributeLocator) function for your requirement.

selenium.getAttribute(//[email protected]);

Specify the Xpath of the element for which you require to know the class.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories