Selenium python find element by class name stopped working from v 2 2 to 2 21 not able to use Compound Class Name

0 votes

I am using Selenium's python library to scrape data from an HTML page in Firefox. I have had to update from Selenium 2.0 to 2.21 because the server has updated Firefox.

In Version 2.21 calls to find_element_by_class_name("grid-cell-inner grid-col-name") fails with:

selenium.common.exceptions.WebDriverException: Message: u'Compound class names not permitted'

The class name of the element I am trying to access is grid-cell-inner grid-col-name

The call to find_element_by_class_name() worked in Version 2.2, so the logic is correct, and the data used to be found OK. Something changed in Version 2.21.

All the Selenium examples give simple examples with class name foo etc, and none with the type of name I need to access.

Why Selenium stopped supporting the finding classes with names like grid-cell inner grid-col-name, and what is the solution?

Kindly let me know how to find elements with "compound" class names?

Aug 23, 2018 in Selenium by Martin
• 4,320 points
5,471 views

1 answer to this question.

0 votes

The problem about WebDriver is that it still evolves. A lot. I personally don't know about a version that supported searching by many classes in one command, so it must have been a fairly old one :).

Searching by a CSS selector should work, however:

find_element_by_css_selector(".grid-cell-inner.grid-col-name");

I don't recommend using XPath for this particular thing, because these two following expressions are a different thing:

//*[class='grid-cell-inner grid-col-name']

//*[class='grid-col-name grid-cell-inner']

answered Aug 23, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

Not able to call onclick datepicker function python selenium

To pass customized dates e.g. 2017/07/14. You have ...READ MORE

answered Jun 8, 2018 in Selenium by Samarpit
• 5,910 points
3,782 views
0 votes
0 answers

How to hover element when action class is not working in my Selenium framework ?

When i am writing the code to ...READ MORE

Feb 16, 2019 in Selenium by Raishul
3,944 views
0 votes
3 answers

How to print text from a list of all web elements with same class name in Selenium?

Try using List <WebElement> to access all similar elements ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
87,563 views
0 votes
1 answer

Not able to upload a file in Selenium Webdriver using python Scripting

Hey Srinivas, you can checkout this code ...READ MORE

answered Sep 10, 2019 in Selenium by Abha
• 28,140 points
4,208 views
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,725 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,166 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,243 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,885 views
0 votes
1 answer

Not able to open a new URL in a new tab in Selenium

There is a bug in ChromeDriver that ...READ MORE

answered May 21, 2018 in Selenium by Meci Matt
• 9,460 points
18,674 views
0 votes
1 answer

How to avoid Compound Class name error in Page Object?

Use a CSS selector instead: .country.name CSS selector is ...READ MORE

answered Jul 31, 2018 in Selenium by Meci Matt
• 9,460 points
1,190 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