开发者

'waitForPageToLoad'/'waitForElementPresent' - how use in Selenium2? (C#)

Guys, I have problem with 开发者_StackOverflow社区waitForPageToLoad condtion. I'm using C# with Nunit, and I don't know exactly what I should use instead of 'waitForPageToLoad'/'waitForElementPresent'. Maybe someone knows how I can use 'waitForPageToLoad'/'waitForElementPresent' in Selenium 2?


I use FindElement() for something on the new page. Wrap in in a loop that will keep trying until the element is found, with a maximum wait.

// pseudocode WebElement wait_for_element(By locator)
while (!timeout) {
  try {
    return driver.FindElement(locator);
  } catch (Exception) {
    Thread.sleep(1000);
  }
  // check for timeout here
}
throw new NoSuchElementException("Timeout waiting for "+locator);


ISelenium selenium = new DefaultSelenium( "localhost", 4444, "*chrome", "
    http://localhost/UrlOfAppToTest/" );
selenium.WaitForPageToLoad( "30000" );

Is that what you're looking for?


You could use a explicit wait method to wait for your action/page to load. With that you can specify a condition to be met, and when it is met your test will continue.

See link for more details: Selenium HQ, explicit wait

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜