Skip to content
Advertisement

Selenium python check if the searched element appears within a period of time

Please help me.

I need to check if an element appears. The element may or may not appear. I want to check if the element appears in an x period of time, but, I still need to refresh the page during this entire period of time, the element does not appear without refreshing the page

wait = WebDriverWait(driver, 9000)
element = wait.until(ec.visibility_of_element_located((By.XPATH,"//b[contains(text(), '" + autor + "')]")))

This code is not what I need, besides what I need to check in x period of time, during this entire period I also need to refresh the page

Advertisement

Answer

Thanks all, solution in my problem:

while True:
if autor in driver.find_element(By.XPATH, "//tbody/tr/td[2]/b").text:
    break
else:
    driver.refresh()
    time.sleep(15)

autor is variable who was receiving a text

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement