问题描述
在使用 appium 和 selenium 进行桌面测试期间,python 中的 if 语句有问题。我的方法:
def test(self,handler):
if handler.find_element_by_name("Exist"):
handler.find_element_by_name("No").click()
else:
print("OK")
第一个条件有效,测试通过并点击“否”按钮。
如果我将条件更改为错误的条件来调用 else,我会得到测试失败和 selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
我不知道为什么这不起作用。另外,当我使用简单的等待时,例如。
WebDriverWait(handler,10).until(EC.presence_of_element_located((By.NAME,"Exist")))
一切正常!
你能帮我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)