Python Forum

Full Version: [Selenium] Element Visible / Invisible | Delay - Best Settings?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this snippet of code that delays the script from moving forward until images are done uploading to a website.

WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//DIV[@class="spinner animation"]')))
WebDriverWait(driver, 20).until(EC.invisibility_of_element_located((By.XPATH, '//DIV[@class="spinner animation"]')))
What settings would you guys use? Is there any better option than a fixed time(driver, 20)? I've been playing around with the settings but it doesn't really run smoothly.
What do you mean it doesnt run smoothly?
(Nov-19-2017, 02:48 PM)metulburr Wrote: [ -> ]What do you mean it doesnt run smoothly?

Just way too much delay.

I think I maybe just need this one line:
WebDriverWait(driver, 1).until(EC.invisibility_of_element_located((By.XPATH, '//DIV[@class="spinner animation"]')))
But even with this one line, and the setting (driver, 1) it delays for 15 seconds after the element has visibly disappeared in the browser. It does move on eventually but I'm confused why it's hanging.

What exactly does this number 1 do? (driver, 1)

Sleep for a 1 second wait until invisibility of element or else just move on?

Wait indefinitely until invisibility of element then sleep 1 second?

Something else?

-

EDIT: this maybe my fault - the site I'm working on is doing a good job hiding the spinner element. all I could grab was the class, I'm not able to hook into anything else to test if that would help.