How to loop through a website and click on things that are not a button Selenium | BeautifulSoup

Question:

I want to loop through this site and click on each element in the list. That means for this example first on:

  1. Die Päpstin
  2. Leo Lausemaus will nicht teilen Pixi …
  3. Löcher – Die Geheimnisse von Green Lake

and so on.

If I take a look on the html of the site I see, that list of elements are stored here:
enter image description here

respectively on element is here:
enter image description here

With the following code, I expected to get an array of objects with all the relevant elements:

driver.get('https://www.booklooker.de/buecher-schnaeppchen')
time.sleep(3)

elements = driver.find_elements(By.CLASS_NAME, 'tooltip')
for test in elements:
   test.click()
   time.sleep(5)

If i run that code snippet, it doesn’t work; that is, nothing happened.

How can I:

  1. get an array with the elements
  2. and how to loop through them?
Asked By: Benedikt Faude

||

Answers:

I believe that the space in your class name is not handled well by Selenium. What happens if you instead use:

elements = driver.find_elements(By.CSS_SELECTOR, '.articleRow.resultlist_productsproduct')
Answered By: C. Peck