Selenium Python Trying to Better Understand WebDriverWait and Splash/Transition Screens

23 Views Asked by At

I'm coding for a website that uses the transition screen below in between each data screen, including when you first connect to the site.

enter image description here

So this screen appears before the initial login screen. My code to sign into the page is:

try:
    #username
    user_val = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "username")))
    user_val.send_keys(usr)

    #password 
    pwd_val = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "password")))
    pwd_val.send_keys(pwd)
    pwd_val.send_keys(Keys.ENTER)
except:
    logger.info("Step 1: Login prompt not found - could not log into Veritas.")

enter image description here

Because of the transition screen it's blowing past this code and hitting the exception. I've been able to correct the problem by putting time.sleep(3) as the first line of code, but I would have thought that using WebDriverWait(browser, 10)...would have searched for this node for 10 seconds before giving up on it. Is that not happening because it's looking for this element on the transition screen? And if that's the case, is there a better way to delay my code until the transition screen has passed? I hate using the time.sleep method but it's the only thing I could think to do.

0

There are 0 best solutions below