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,220 points
697 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,400 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,130 points
900 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 15 in Selenium by Raishul
220 views
0 votes
1 answer
0 votes
1 answer

Not able to use “explicit wait” in my code

To wait until the entire data has ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
70 views
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,050 points
416 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
773 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
410 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,400 points
6,806 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,400 points
43 views