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

Time:09-04

I want to loop through 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?

CodePudding user response:

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')
  • Related