We tried using the implicit wait functionality, but it wasn't working
for us. I don't know if it was the way we set it, or if it's just the
way WebDriver is interacting with a GWT application, or maybe
something in WebDriver itself... We set it through the
driver.manage().timeouts().implicitlyWait() method, but it just didn't
seem to do any polling. :-\
I've pasted in the method we use to fire up a new WebDriver, if anyone
cared to take a look and see if we were setting it incorrectly...
public WebDriver newBrowser(BrowserType browserType)
{
WebDriver newBrowser;
// If browserType is "random", randomly pick one of the first 3
browsers Firefox, Chrome, or IE.
if (browserType.equals(BrowserType.random))
{
browserType = BrowserType.values()[new Random().nextInt(3)];
}
// Which browser are we testing with?
switch (browserType)
{
case chrome:
String chromeDriverExePath =
System.getProperty("chrome.driver.exe.location");
if (chromeDriverExePath == null)
chromeDriverExePath = "";
System.setProperty("webdriver.chrome.driver",
chromeDriverExePath + "../extras/chromedriver.exe");
// Next 2 lines are necessary to run Chrome browser
maximized
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
newBrowser = new ChromeDriver(options);
break;
case htmlunit:
newBrowser = new HtmlUnitDriver(true);
break;
case ie:
// To test with IE, enable "Protected Mode" in the
Security tab of the Internet Options
newBrowser = new InternetExplorerDriver();
// Workaround to maximize, until WebDriver issue 174 is
resolved.
newBrowser.findElement(By.xpath("//
html")).sendKeys(Keys.F11);
break;
case opera:
newBrowser = new OperaDriver();
case firefox:
default:
newBrowser = new FirefoxDriver();
// Workaround to maximize, until WebDriver issue 174 is
resolved.
newBrowser.findElement(By.xpath("//
html")).sendKeys(Keys.F11);
break;
}
// Set the default implicit timeout, how long it will wait before
// failing when you look for an element that doesn't exist.
newBrowser.manage().timeouts().implicitlyWait(Integer.parseInt(testEnvironment.getProperty("DefaultWaitTime")),
TimeUnit.SECONDS);
return newBrowser;
}
On Jan 17, 6:04 am, Ross Patterson <
rpatter...@parature.com> wrote:
> It sounds like you're re-inventing WebDriver's "implicit wait" facility. You should give it a try. Check outhttp://
seleniumhq.org/docs/04_webdriver_advanced.htmlfor an explanation.