1

Fist of all here is the picture of the HTML code: HTML

This is the element I tried to access: Class

I tried: driver.find_element_by_class_name("btn_green_white_innerfade btn_medium market_commodity_buy_button")

... but it threw up an error. Error Code

I would be glad for any help!
Regards
-Eirik

1
  • It would be useful if you provided us with the link to that site and your code. Commented Sep 27, 2021 at 17:48

2 Answers 2

1

In Selenium, class name do not have support for spaces. Please remove spaces and put . instead to make a css_selector.

Instead of

driver.find_element_by_class_name("btn_green_white_innerfade btn_medium market_commodity_buy_button")

do this :

driver.find_element_by_css_selector("a.btn_green_white_innerfade.btn_medium.market_commodity_buy_button")
Sign up to request clarification or add additional context in comments.

1 Comment

Also, your application is angular based, please put some delays or webdrivewait to let the element rendered properly and then try to access them.
0

Compound class names are not permitted in Selenium. Locates elements whose class name contains the search value. i.e. you won't be able to pass multiple class names. If you pass multiple class names then you will get compound class name exception.

Wrong way:

By.className("alert alert-class")

Right way:

By.className("alert.alert-class")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.