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
  • Is the url a public url? Commented Jul 23, 2022 at 15:58

1 Answer 1

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
    
Sign up to request clarification or add additional context in comments.

4 Comments

for my question the URL is 'google.com/…' . 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?
the error is InvalidSelectorException .
I updated my question with new images I think it makes my question clear.
Checkout the updated answer and let me know the result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.