"select"コントロールから値を選択するSelenium 2テスト(C#で書かれています)を使用しています。選択すると、サーバーへのポストバックが発生し、ページの状態が更新されます。したがって、私は手動待機(thread.sleep
)を実行して、ページが変更されるのを待つ値を選択しています。 Thread.Sleepでうまく動作します。しかし、Thread.Sleep
は、私は、コードのすべての私のThread.Sleep
ラインを取るように良い理由の数で使用する悪い考えでは、すべての私のテストケースがバラバラになると私はWebDriverWaitを試してみました、暗黙的および明示的にどれも機能していないと非常に不満であるWebDriverWaitまたはImplicitlyWaitまたはExplicitlyWaitは機能しません
以下、私が試してみましたサンプルコード....
がある// WebDriverWait
public IWebElement WaitForElement(By by)
{
// Tell webdriver to wait
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.PollingInterval = TimeSpan.FromSeconds(2);
wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(NoSuchFrameException));
wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException), typeof(StaleElementReferenceException));
IWebElement myWait = wait.Until(x => x.FindElement(by));
return myWait;
}
はこれも試しました:
WebDriverWait wait = new WebDriverWait(new SystemClock(), driver, TimeSpan.FromSeconds(30), TimeSpan.FromMilliseconds(100));
//暗黙:
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
//明示的な待ち:
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://somedomain/url_that_delays_loading";
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Id("someDynamicElement"));
});
はい私が試したが、うまくいきませんでした。 –