Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display wait time WebDriverWait using selenium python

I'm interesting in getting the time waited until an object was clickable on the page. So once the element is clickable a metric is displayed showing how long it took for the element 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 that I am using to poll for the element, but I'm looking for a way to get time waited metric out.

Any suggestions ?

like image 775
buttonpresser Avatar asked May 08 '26 08:05

buttonpresser


1 Answers

You will not get the exact time, as because you have polling every N seconds and the overall wait. But you can have the average approximation. It's not only for Selenium purposes, but you can use import time, for example.

  • just before executing the command add: start = time.time()

  • and right after the command: end = time.time()

  • then, the needed value will be print end - start

like image 54
Stan E Avatar answered May 09 '26 22:05

Stan E



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!