Getting CSS class name using Selenium Webdriver

0 votes

I was trying to fetch css class name using eclipse and Java.

<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>       

</table>

How can I get the class name 'odd' or 'even' using selenium? 

Apr 9, 2018 in Selenium by Johnathon
• 9,080 points
156 views

1 answer to this question.

0 votes

You can use getAttribute(attributeLocator) function.

 selenium.getAttribute(//xpath@class);

You have to specify the Xpath of the element for which you require to know the class of.

answered Apr 9, 2018 by ghost
• 1,790 points

Related Questions In Selenium

0 votes
1 answer

Locating an element by value using css selector using Selenium WebDriver

Below code will help By.cssSelector("td[class='someclass'][value='u ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,020 points
145 views
0 votes
1 answer
0 votes
1 answer

Getting "Disable developer" mode extensions pop up while using Selenium WebDriver

Try the following java code: System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe"); ChromeOptions chrome ...READ MORE

answered May 21, 2018 in Selenium by Meci Matt
• 9,420 points
702 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
955 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,124 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
861 views
0 votes
1 answer
0 votes
1 answer

Differences between Implicit wait Vs. Explicit wait in selenium webdriver

Implicit Wait - It instructs the web driver ...READ MORE

answered Apr 9, 2018 in Selenium by ghost
• 1,790 points
1,535 views