1

When using Selenium I tried to scroll down the page but I don't know how to click on the link with text See more anyway.

enter image description here

enter image description here

1 Answers1

1

To click on the element with text See more anyway you need to induce WebDriverWait for the element_to_be_clickable() which automatically scrolls the element within view and you can use the following locator strategy:

  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[contains(., 'The rest of the results')]//span[contains(., 'See more anyway')]"))).click()
    
  • Or simply:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(., 'See more anyway')]"))).click()
    
  • 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
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • for my question the URL is 'https://www.google.com/search?q=aircrafts+jongle&rlz=1C1CHBF_enUS985US986&sxsrf=ALiCzsYbdeL-qTiWpKJjzeWFvdclyE9CNA:1658590199885&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiYosT9qY_5AhVspIkEHUewB4AQ_AUoAXoECAEQAw&biw=1536&bih=746&dpr=1.25' . using your code I got error. I think this is because there is not any button. could you please let me know how to fix it. Do I have to edit anythings? – Fateme Nazari Jul 23 '22 at 19:06
  • the error is InvalidSelectorException . – Fateme Nazari Jul 23 '22 at 19:14
  • I updated my question with new images I think it makes my question clear. – Fateme Nazari Jul 23 '22 at 19:22
  • Checkout the updated answer and let me know the result. – undetected Selenium Jul 23 '22 at 19:35