How to handle element not found exception in Protractor(如何处理量角器中未找到元素的异常)
问题描述
就像 Selenium webdriver 为 Java 提供了各种异常处理一样,有什么方法可以使用 Protractor 来实现.
Just like Selenium webdriver provides various Exception handling for Java, is there any way we can achieve same using Protractor.
如果我们想处理 element not found 异常,那么使用 Protractor 最好的方法是什么?
If we want to handle element not found exception, then what is the best way to do it using Protractor?
推荐答案
回答这个问题现在在 Protractor 的常见问题解答中
当命令无法完成时,WebDriver 会抛出错误 - 例如无法单击被另一个元素遮挡的元素.如果您需要重试这些操作,请尝试使用 webdriverjs-retry.如果您只想捕获错误,请这样做
WebDriver throws errors when commands cannot be completed - e.g. not being able to click on an element which is obscured by another element. If you need to retry these actions, try using webdriverjs-retry. If you would just like to catch the error, do so like this
根据您的问题改编:
elm.isPresent().then(function(present) {
/* no webdriver js errors here *
本文标题为:如何处理量角器中未找到元素的异常


基础教程推荐
- Chart.js 在线性图表上拖动点 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 直接将值设置为滑块 2022-01-01