0

I'm trying to use WebDriverWait in order to check if I can see the expected dashboard url got loaded and also I check for the presence of an mandatory logo. I have the relevant code below,

if WebDriverWait (driver, 30).until(EC.url_to_be(<expected_dashboard_url>) and driver.find_elements_by_id(<logo_id>):
    print("Successful")

I see that the dashboard url gets loaded properly on the browser with the expected mandatory logo on page as well but on my console I don't see "Successful" message, insted it keeps waiting and leads to TimeoutException.

Note : All necessary imports done and webdriver instantiated correctly.

Rahul S L
  • 1
  • 3
  • The confusing part is if I try to run the script 5 times, 1 time I see Successful and rest of the 4 times I see the TimeoutException even though page is loaded properly. – Rahul S L Jun 10 '21 at 05:51

1 Answers1

0

If I understood the problem correctly, you can try this ;

browser.get("url")
delay = 5
try:
    element = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.ID, 'id')))
except TimeoutException:
    print "not loaded"

I encountered this problem before and solved it with the solutions in this link. If that doesn't work you can have a look;

Wait until page is loaded with Selenium WebDriver for Python