Issue
I want to loop through this site and click on each element in the list. That means for this example first on:
- Die Päpstin
- Leo Lausemaus will nicht teilen Pixi ...
- 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:
respectively on element is 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:
- get an array with the elements
- and how to loop through them?
Solution
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.