Python selenium timeout exception without message when clicking

Python selenium timeout exception without message when clicking

Problem Description:

I want to search specific word in ScienceDirect and when is shows results I want to click 100 result per page at the bottom on page.

HTML code:

<a class="anchor" data-aa-region="srp-pagination-options" data-aa-name="srp-100-results-per-page" href="/search?qs=Python&amp;show=100"><span class="anchor-text">100</span></a>

And that’s my code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from import By
from import WebDriverWait
from import expected_conditions as EC

driver = webdriver.Chrome()
assert "Science" in driver.title
elem = driver.find_element(By.ID, "qs-searchbox-input")
assert "No results found." not in driver.page_source
element = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, ".data-aa-name[value='srp-100-results-per-page']"))

And exception:

Traceback (most recent call last):
  File "", line 15, in <module>
    element = WebDriverWait(driver, 10).until(
  File "", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

Solution – 1

Use for example this CSS selector:

 "div#srp-pagination-options li:nth-child(3)"
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.