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,090 points
1,645 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=' ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,090 points
2,135 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,460 points
2,905 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,763 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
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,910 points
7,258 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,896 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
3,825 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP