本文介紹了如何處理量角器中未找到元素的異常的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
就像 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 *
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!