Given this code that waits until a loading circle disappears from a webpage :
def wait_loadingCircle(self):
try:
while self.browser.find_element_by_xpath('//div[@class="sk-circle-container"]').is_displayed() is True:
time.sleep(1)
except (NoSuchElementException, StaleElementReferenceException, TimeoutException):
print('Loading circle has expired')
The problem is when the circle disappears (the xpath disappears) .is_displayed() function returns false in 12+ seconds, is there any other way to wait until the circle disappears(xpath is not found on the page anymore) ?
Edit:
This sample of code takes even longer:
def wait_loadingCircle(self):
try:
# while self.browser.find_element_by_xpath('//div[@class="sk-circle-container"]').is_displayed() is True:
while self.browser.find_element_by_xpath('//div[@class="sk-circle-container"]') != None:
time.sleep(1)
except (NoSuchElementException, StaleElementReferenceException, TimeoutException):
print('Element loading a disparut')
Basically after the xpath disappears from the page the code is sooo slow to identify it when the page is just abit bigger in complexity