I have a problem with if statement in python durring desktop testing using appium and selenium. My method:
def test(self, handler):
if handler.find_element_by_name("Exist"):
handler.find_element_by_name("No").click()
else:
print("OK")
First condition works, the test passes and clicks the "No" button.
If I change the condition to one that's false to call the else, I get test failed and selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
I don't know why this is not working. Also, when I use simple wait, eg.
WebDriverWait(handler, 10).until(EC.presence_of_element_located((By.NAME, "Exist")))
everything works fine!
Could you help me?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…