learner
learner

Reputation: 43

Webdriver not finding element on page

I am using Selenium Webdriver with Python to access a div element containing links. Webdriver is unable to find this div for some reason. Other div elements on the page seem like they are randomly findable by webdriver. Here is the html of the page:

Image of html of page

Highlighted is the div I need to select. All other class names within this div are unfindable too. Codes I have tried for finding elements:

driver.find_element_by_class_name('carouselNav__listWrapper recipeCarousel__listWrapper')
driver.find_element_by_css_selector("carouselNav__listWrapper recipeCarousel__listWrapper")

Error I am getting:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".carouselNav__listWrapper recipeCarousel__listWrapper"} (Session info: chrome=92.0.4515.131)

I do not understand what I am doing wrong. Any help appreciated.

Upvotes: 2

Views: 99

Answers (1)

cruisepandey
cruisepandey

Reputation: 29382

No class name do not work with spaces, and in css you can combine them like this :

driver.find_element_by_css_selector(".carouselNav__listWrapper.recipeCarousel__listWrapper")

Upvotes: 1

Related Questions