timeoutException 방법을 재정의함으로써, 우리는 대기 시간 초과 다른 예외를 트리거 할 수 있습니다. timeoutException 메서드를 덮어 쓰는 다음 코드를 고려하십시오. 타임 아웃이 발생하면
FluentWait<WebDriver> wait=new FluentWait<WebDriver>(driver){
@Override
protected RuntimeException timeoutException(String Message,Throwable lastException)
{
throw new MyException("A New Exception instead of TimeOutException");
}
};
wait.ignoring(NoSuchElementException.class)
.withTimeout(2, TimeUnit.SECONDS);
WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
});
은 그래서, 대신 TimeoutException의, 사용자 정의 예외는 ERKI을
com.example.tests.MyException: A New Exception instead of TimeOutException
at com.example.tests.sampleTest$1.timeoutException(sampleTest.java:40)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at com.example.tests.sampleTest.test(sampleTest.java:45)
감사를 던져, 그러나 이것은 내가, 내가 셀레늄을 공부하고 무엇을 찾고 있었다하지 않고 방법을 이해할 수있을 것이다 timeoutException을 제외한 FluentWait의 다른 메소드를 사용하십시오. 보호 된 방법에 대한 힌트에주의를 기울임으로써 그 사용법을 알아 내고 대답으로 업데이트 할 수있었습니다. – Kavan