'How to know if element appear and then disappear in selenium python ' is_displayed() issues '
In the website i'm trying to automate, when the internet connection get lost a notification you can access to it by a class name appears at the top of the page and tells you that there is no internet and i want to code something that let you pause the process until the internet get back
and i'm tying to reack that by .is_displayed() which return a True value after checking that the notification appears and it's working fine but when i tried to check the disappear of the element it show me an error
except:
#time.sleep(3)
if driver.find_element(By.CLASS_NAME, "HGcYc4pY").size['width'] != 0 :
print ('internet lost')
while True:
c= driver.find_element(By.CLASS_NAME, "HGcYc4pY").is_displayed()
if driver.find_element(By.CLASS_NAME, "KhLQZTRq pxYtrw1j D56bmevE").is_displayed() == True:
print("still lost")
if driver.find_element(By.CLASS_NAME, "KhLQZTRq pxYtrw1j D56bmevE").is_displayed() == False:
print("interent is back")
break
print("did it ")
I tried this and it's just the same it doesn't work when the notification disappear aggain
except:
#time.sleep(3)
if driver.find_element(By.CLASS_NAME, "HGcYc4pY").size['width'] != 0 :
print ('internet lost')
while True:
if driver.find_element(By.CLASS_NAME, "HGcYc4pY").size['width'] != 0:
print("still lost")
if driver.find_element(By.CLASS_NAME, "HGcYc4pY").size['width'] == 0:
print("interent is back")
break
print("did it ")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
