Show WebDriverWait timeout using selenium python
I'm interested in the time to wait until the object is available on the page. Therefore, when an item is clickable, a metric is displayed showing how long it took for the item to become active.
try:
WebDriverWait(self.driver, 10, poll_frequency=0.5).until( lambda d: self.submit_button)
except TimeoutException:
assert False
Above is the code I am using to poll for an item, but I am looking for a way to get the timeout.
Any suggestions?
source to share
You won't get the exact time because you have a poll every N seconds and a total wait. But you can have an average approximation. This is not only for Selena purposes, but you can use import time
for example.
-
before executing the add command:
start = time.time()
-
and right after the command:
end = time.time()
-
then the required value would be
print end - start
source to share