0

I have a dashboard with several charts. Until a chart is loaded it displays

Loading...

The page is fully loaded, when in all charts Loading... isn't visible anymore.

Loading... is one class embeded in all chart divs. Each chart has an id that changes with every reload.

<div id="loadmask-3379-msgTextEl" data-ref="msgTextEl" class="x-mask-msg-text" role="presentation">Loading...</div>

I can easily wait for one element with the line below but don't know how until all have disappeared:

WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.XPATH,"//div[contains(text(),'Loading')]")))

How can I implement in Selenium with Python and on Edge an explicit wait until Loading... disappeared in all charts?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Daniel
  • 59
  • 4

2 Answers2

0

You can keep trying to find the element until none is found.

Gibon
  • 64
  • 5
  • Do I have to put the wait into a loop or do you mean this alone waits until all 'loading' have disappeared. I thought it wait's only for the first one. – Daniel Aug 19 '22 at 08:59
  • you put in the loop which ends when nothing is found. Use find_element function in try statement and break the loop when it raises NoSuchElementException. Or you can use find_elements and check if the returned list is empty. I would go with 2nd option. – Gibon Aug 19 '22 at 09:09
0

To wait for all the loader elements to disappear you can use either of the following locator strategies:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks a lot and makes sense. Now seems (visibility_of_all_elements_located...) is not accepted: NameError: name 'visibility_of_all_elements_located' is not defined When I'm building the term visiblity is not offered as valid entry. Without the 'none_of' it's accepted – Daniel Aug 19 '22 at 10:10
  • Just for a quick test can you replace `visibility_of_all_elements_located((By.XPATH,"//div[contains(text(),'Loading')]"))` with `WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[contains(text(),'Loading')]")))` – undetected Selenium Aug 19 '22 at 10:14
  • This works. Seems none_of causing the issue. – Daniel Aug 19 '22 at 10:36
  • Well, my recommendation was on R&D basis. Do you want to say the second option from the updated answer worked? I would have loved to get your feedback and a discussion in the [Selenium](https://chat.stackoverflow.com/rooms/223360/selenium) room. – undetected Selenium Aug 19 '22 at 10:49
  • Hello. No the second option results in this error: TypeError: 'list' object is not callable – Daniel Aug 19 '22 at 11:10
  • _This works_: Which approach worked :) – undetected Selenium Aug 19 '22 at 11:13