格子縞のシャツ:
df778899:
これに対する典型的な解決策は、待機に対してのtry / catchです。例えば次のステップは、ローディング完了すると表示されていること、ボタンをクリックする場合:
WebDriverWait wait = new WebDriverWait(driver, LOADING_TIMEOUT);
WebElement webElement;
try {
webElement = wait.until(elementToBeClickable(By.id(id)));
} catch (TimeoutException ex) {
// Close loading window
return;
}
webElement.click();
あなたはセレンで暗黙のタイムアウトを使用している場合は、一般的な問題があります。これは、暗黙のタイムアウトはポーリングサイクルダウンこの遅くなるよう、LOADING_TIMEOUTより長い場合は特に、あまりうまく機能しませんwait.until()
。
この場合、最も簡単な解決策は一時的に暗黙のタイムアウトを減らすことです。
WebDriverWait wait = new WebDriverWait(driver, LOADING_TIMEOUT);
WebElement webElement;
try {
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
webElement = wait.until(elementToBeClickable(By.id(id)));
} catch (TimeoutException ex) {
// Delay any further interaction until the timeout has been restored
webElement = null;
} finally {
driver.manage().timeouts().implicitlyWait(DEFAULT_TIMEOUT,
TimeUnit.SECONDS);
}
if (webElement != null)
webElement.click();
else
// Close loading window