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 selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://www.sciencedirect.com/")
assert "Science" in driver.title
elem = driver.find_element(By.ID, "qs-searchbox-input")
elem.clear()
elem.send_keys("Python")
elem.send_keys(Keys.RETURN)
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']"))
)
element.click()
driver.close()

And exception:

Traceback (most recent call last):
  File "X:pythonProjectseleniumcount_cited.py", line 15, in <module>
    element = WebDriverWait(driver, 10).until(
  File "X:pythonProjectseleniumvenvlibsite-packagesseleniumwebdriversupportwait.py", 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.
Accept
Reject