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,050 points
74 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 1,980 points
59 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,400 points
368 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,030 points
73 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
446 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
55 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
988 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.