I got a running code, but sometimes I get timeout in 30 seconds, sometimes in 80 or more (depends on server side), so the point is - how to make my code stop once I can view the element and not to wait until 120 seconds passed? Well, what I am trying to achieve is stop the code once the element is NOT PRESENTED on the screen:
def isElementPresent(self):
try:
wait = WebDriverWait(self.driver, 120)
wait.until(EC.invisibility_of_element_located((By.NAME, 'GETTING NEW IMAGE FROM HOME SYSTEM')))
except TimeoutException:
print('Camera Timeout')
'GETTING NEW IMAGE FROM HOME SYSTEM'? IS the value changed every loop? I'm just curious why you need that loop.whileloop immediately. Otherwise, it will print 'Camera Timeout' and then go to next loop, and wait for the element for 120 sec. again. The point is the timeout error is always at 120 sec. But the time to break the loop depends on how long does it take to find the element.isElementPresent? Can you show more code?