I am using the time
library in my script:
import time
time.sleep(1)
It can sleep my webdriver for 1 second but I need to sleep it for 250 milliseconds.
I am using the time
library in my script:
import time
time.sleep(1)
It can sleep my webdriver for 1 second but I need to sleep it for 250 milliseconds.
If you want it to sleep in milliseconds then use float values:
time.sleep()
takes a floating-point argument:Docs (they're worth a read not least because they explain the conditions under which the sleep could end up being shorter or longer than expected).
To suspend the execution of the webdriver for milliseconds you can pass
number of seconds
orfloating point number of seconds
as follows:However while using Selenium and WebDriver for Automation using
time.sleep(secs)
without any specific condition to achieve defeats the purpose of Automation and should be avoided at any cost. As per the documentation:So as per the discussion instead of
time.sleep(sec)
you should useWebDriverWait()
in-conjunction withexpected_conditions()
to validate an element's state and the three widely used expected_conditions are as follows:presence_of_element_located
presence_of_element_located(locator) is defined as follows :
visibility_of_element_located
visibility_of_element_located(locator) is defined as follows :
element_to_be_clickable
element_to_be_clickable(locator) is defined as follows :
Reference
You can find a detailed discussion in WebDriverWait not working as expected