は、だから私はExpectedCondition
に私の要素のベースを待ち、この汎用的な機能を持っている:セレン:無視する方法より2例外その後、
def findMyElement(expectedCondition: (By) => ExpectedCondition[WebElement], by: By, timeOut: Long): WebElement = {
createFluentWait(timeOut).until(expectedCondition(by))
driver.findElement(by)
}
def createFluentWait(timeOut: Long): FluentWait[WebDriver] = {
new FluentWait[WebDriver](driver)
.withTimeout(timeOut, TimeUnit.SECONDS)
.pollingEvery(1, TimeUnit.SECONDS)
.ignoring(classOf[NoSuchElementException], (classOf[StaleElementReferenceException]))
}
だから私の質問はするために私のcreateFluentWait
関数に別のExceptions
を追加する方法でありますタイムアウトする前にException
を避ける?
複数の例外を追加するとよいですか?またはそれを避けるために多分?私はタイムアウトに達するまで試してみたい、ElementNotVisibleExceptionとNoSuchElementExceptionも無視したい。 –
何が例外になっているのか、なぜ起こっているのか、それが予期しているかどうかによります。私は、 'NoSuchElementException'と' StaleElementReferenceException'が私が使用する唯一の2つであることがよくあります。 –
例外の注文にも問題はありますか? –