I am writing a code that will hopefully be able to click on a defined button on a pop-up window. The pop-up window appears only after having clicked somewhere else (this part is working).
here's the code:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
wait = WebDriverWait(driver, 2)
wait.until(EC.element_to_be_clickable((By.XPATH, '//button\[text()="OK"\]')))
wait.until(ExpectedConditions.visibilityOfElementLocated(By.XPATH, '//button\[text()="OK"\]'))
wait.until(ExpectedConditions.elementToBeClickable(By.XPATH, '//button\[text()="OK"\]'))
driver.findElement(By.XPATH, '//button\[text()="OK"\]').click()
I am getting an error "TimeoutException". Anyone able to fix that?
thanks a lot
HTMLsource for that element you want to clickTimeoutExceptionmeaning one of the 3 web elements you trying to locate fail and hit timeout error. You need to provide more details such as the URL or site that you are trying to access. Or at least some sample HTML source to determine if your locator is working properly.