상태가 특정 "완료 됨"상태가 될 때까지 기다릴 셀렌에서 작업을 수행하려고합니다.중간 작업의 셀레늄 조건부 대기
개념적으로는이 같은 의사 코드에 배치 할 수 있습니다
public boolean waitForActionToComplete(long maxTimeoutInSeconds, int repeatTimeInSeconds, Callable<T> action, Callable<T> condition) {
long startTime = 0;
while (startTime < maxTimeoutInSeconds)
perform <action>; // e.g., click on a "Refresh" button to refresh the results
boolean done = verify <condition>; // e.g., check whether the job status is "Done"
if (done)
return true; // if done, then exit with TRUE
else
Thread.sleep(repeatTimeInSeconds);
end while;
return false; // status still not complete, timeout gracefully
}
이 방법은 가능성이 ExpectedCondition 및 WebdriverWait/FluentWait 다소 쉬운 방법으로 구현 될 수있다. 그러나 프레임 워크의 특정 제약으로 인해 필자는이 방법을 정확하게 구현하고 사용할 수 없습니다. 이 (이 방법 서명을 가진 프레임 워크의 인터페이스를 구현)로 위의 방법이 구현되어야 할 것이다 :
public void execute(final WebDriver webDriver, String... parameters) {
// implementation here
}
사람이 어떻게 위에 지정된 형태의 방법을 변환하는 방법을 말해 줄래?
당신은 [WebDriverWait] 조사해야합니다 (HTTPS : //seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/WebDriverWait.html) 및 [FluentWait] (https://seleniumhq.github.io/selenium/docs/ api/java/org/openqa/selenium/support/ui/FluentWait.html). – JeffC
감사합니다. JeffC. 감사합니다. 말된다. 나는 위의 성명서가 완전하지 않다고 생각했다. 나는 그것을 지금 완료했다. – naspras
FluentWait으로 설명한 내용을 여전히 수행 할 수 있습니다. 당신은'verify'이 무엇이든 상관없이 그 자체로 구현해야 할 것이다. –
JeffC