1

I'm trying to scrape all list from URL: https://trends.google.com/trends/yis/2021/ID/ Before I scrape all the items in lists, I want to open all items by clicking all the show more buttons. how can I click all the show more buttons with Selenium and Python?

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

url = "https://trends.google.com/trends/yis/2021/ID/"

driver = webdriver.Firefox()
driver.get(url)

try:
  element = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "show-more")))
  for i in element:
      i.click()
except Exception as e:
  print(e)
  driver.quit()

This code show this error:

Message: Element could not be scrolled into view Stacktrace: WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5 ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.jsm:291:5 webdriverClickElement@chrome://remote/content/marionette/interaction.js:156:11 interaction.clickElement@chrome://remote/content/marionette/interaction.js:125:11 clickElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:200:24 receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:91:31

  • Does this answer your question? [python selenium click on button](https://stackoverflow.com/questions/21350605/python-selenium-click-on-button) – adrianop01 Dec 12 '21 at 03:14
  • @adrianop01 I'm new to Selenium and web dev, I think the problem is a little bit different. I've just added my source code and the error, can you look at it and fix the code? Thanks. – Adrian Maulana Dec 12 '21 at 09:17

0 Answers0