Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is selenium reaching timeout when the element is there

i have a problem code below where the element becomes visible and is not clicked. i tried both css selectors and the xpath.

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


PROXY = "socks5://184.178.172.13:15311"  # IP:PORT or HOST:PORT

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

driver = webdriver.Chrome(chrome_options=chrome_options)

driver.get('https://nitrogensports.eu/sport/tennis/starting-soon')
wait = WebDriverWait(driver, 30)
table = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="modal-welcome-new-button"]')))
table.click()
table = wait.until(EC.presence_of_element_located((By.XPATH, '//div[class="div.events-result-set"]')))
print("finished")
time.sleep(30)
driver.close()
like image 844
Felix Farquharson Avatar asked Jan 24 '26 21:01

Felix Farquharson


1 Answers

As per your question the element identified as (By.XPATH, '//*[@id="modal-welcome-new-button"]') is not getting clicked.

Once the wait is over and the element is identified and returned back, moving forward as you are invoking click() method so instead of using the expected_conditions method presence_of_element_located you need to use the method element_to_be_clickable as follows :

driver.get('https://nitrogensports.eu/sport/tennis/starting-soon')
WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='party-button highlightable-button highlighted' and @id='modal-welcome-new-button']"))).click()
like image 117
undetected Selenium Avatar answered Jan 26 '26 11:01

undetected Selenium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!