Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

If statement using apium and selenium in python desktop testing

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...