Home > Mobile >  How to click on the See all button using Selenium and Python
How to click on the See all button using Selenium and Python

Time:11-22

This script with Selenium in Python 3 helps me to scrape data from a page by clicking the see all button, but it stopped working and I do not know the cause. Could you help me with the code?

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

nav= Service(ChromeDriverManager().install())
driver= webdriver.Chrome(service= nav)

driver.get('https://getdaytrends.com/es/venezuela/#moreTrends')
                   
driver.find_element(By.CLASS_NAME,'btn btn-outline-primary px-5')
driver.execute_script("arguments[0].click();", search)

datos= driver.find('table')

The Traceback is:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".btn btn-outline-primary px-5"}

CodePudding user response:

To click on Ver todo 34 you need to scrollIntoView() the desired element and induce getdaytrends

Note: You have to add the following imports :

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

References

You can find a couple of relevant discussions on NoSuchElementException in:

  • Related