本文介绍了selenium 两个 xpath 测试合二为一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我尝试结合检查两种情况:
I try to combine check for two scenarios:
如果启动检查失败,我们会得到一个重试按钮:
If startupcheck fails we get a try again button:
或者 startupcheck 成功我们在一个自定义对象中得到一个 pin 输入请求:
Or startupcheck succeed we get a pin enter request in a custom object:
如何将其合并为一项检查而不必同时检查两者:我尝试了以下方法:
How can this be combined into one check without having to check for both: I tried the following:
但只检查第一个 or
语句.
But only the first or
statement is checked.
推荐答案
您可以通过 lambda 表达式使用 OR
子句对两个元素进行组合检查,如下所示:
You can club up combine check for both the elements using OR
clause through a lambda expression as follows:
另一种解决方案是:
作为替代方案,您可以使用等效的 css-selectors 如下:
参考文献
- Python/Selenium:WebDriverWait 中的逻辑运算符预期条件
- 如何通过getText()从html内的多个子节点中提取动态文本
这篇关于selenium 两个 xpath 测试合二为一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!