1

When I interact with the page, loader appears for couple of seconds, and then it disappears completely from page html.

<div class="loader">
<img src="/static/media/loading-anim-windmill.9f645983.gif" alt="loading"><p>Loading...</p>
</div>

for waiting this element to appear i simply write

element = WebDriverWait(elem, 10).until(EC.element_to_be_clickable((by, val)))

but how do I know when did it disappear? and how do i measure this time range?

Prophet
  • 32,350
  • 22
  • 54
  • 79
Saba
  • 416
  • 3
  • 14

1 Answers1

2

Similarly to element_to_be_clickable expected condition there are invisibility_of_element_located and invisibility_of_element expected conditions.
So, to wait for element to disappear you can do something like this:

wait = WebDriverWait(driver, 10)
wait.until(EC.invisibility_of_element((By.CSS_SELECTOR, "the_css_selector")))

To measure the time the elements disappears you can do as following:

startTime = time.time()
wait = WebDriverWait(driver, 10)
wait.until(EC.invisibility_of_element((By.CSS_SELECTOR, "the_css_selector")))
finishTime = time.time()
print(finishTime-startTime)
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • I guess the OP wants the timedelta between ... some moment in time when the loading starts, and the moment the expected element is fully visible. So maybe get the timestamp when Element A becomes visible, and then timestamp when Element B is visible. – Barry the Platipus Oct 12 '22 at 15:42
  • @BarrythePlatipus I see OP is asking ` how do I know when did it disappear? and how do i measure this time range?` This is what I tried to answer here. But maybe I misunderstood something – Prophet Oct 12 '22 at 15:46
  • I guess the OP now has a proper answer. +1. – Barry the Platipus Oct 12 '22 at 15:47
  • My code is in python, but still thanks works the same as in C#. – Saba Oct 13 '22 at 07:13
  • 1
    I'm sorry. I mixed python with Java :) Now it is fixed – Prophet Oct 13 '22 at 07:19