If you look at the API Docs of WebDriverWait
it is defined as :
class selenium.webdriver.support.wait.WebDriverWait(driver, timeout, poll_frequency=0.5, ignored_exceptions=None)
Constructor, takes a WebDriver instance and timeout in seconds.
Further the untill method is defined as :
until(method, message='')
Calls the method provided with the driver as an argument until the return value is not False.
So both WebDriverWait
constructor and until
method is associated with the WebDriver
instance which is extensively used to communicate with Browser Clients. Hence WebDriver
may not help you.
Having said that different solutions are available through Python
.
Solution # 1
You can import the time and datetime module of Python
to sleep()
in a simple loop as follows :
import datetime
import time
# datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
# The year, month and day arguments are required. tzinfo may be None.
target_time = datetime.datetime(2018, 1, 23, 13, 2, 00) # 13:02 pm on 23 January 2018
while datetime.datetime.now() < target_time:
time.sleep(10)
print("It is 13:02 pm, 2018. Resuming Test Execution")
Solution # 2
You can import the Timer object from threading module of Python
to induce a timer
as follows :
from threading import Timer
def hello():
print("Hello World")
t = Timer(10.0, hello)
t.start() # after 30 seconds, "Hello World" will be printed
Trivia
You also use the Event scheduler Class sched
which implements a general purpose event scheduler:
class sched.scheduler(timefunc=time.monotonic, delayfunc=time.sleep)