Add configurable wait time when grabbing root html element #269

Closed
geb-bot opened this Issue Nov 25, 2013 · 3 comments

Projects

None yet

2 participants

@geb-bot
geb-bot commented Nov 25, 2013

Originally created by Craig Atkinson.

When running Geb tests on our slow CI server, we run into exceptions similar to this one about every 100 tests.

{noformat}
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"tag name","selector":"html"}
Command duration or timeout: 576 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.37.1', revision: 'a7c61cbd68657e133ae96672cf995890bad2ee42', time: '2013-10-21 09:08:07'
System info: host: 'cloud01', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-24-generic', java.version: '1.6.0_38'
Session ID: 5ee2f1f0-0287-44fd-bfd0-459e7a5a01b6
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=19.0.2, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByTagName(RemoteWebDriver.java:372)
at org.openqa.selenium.By$ByTagName.findElement(By.java:336)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at geb.navigator.factory.BrowserBackedNavigatorFactory.getBase(BrowserBackedNavigatorFactory.groovy:33)
at geb.content.NavigableSupport.getNavigator(NavigableSupport.groovy:39)
at geb.content.NavigableSupport.$(NavigableSupport.groovy:72)
at geb.content.PageContentTemplateFactoryDelegate.methodMissing(PageContentTemplateFactoryDelegate.groovy:34)
at Page.groovy:11)
at geb.content.PageContentTemplate.invokeFactory(PageContentTemplate.groovy:97)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:59)
at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
at geb.content.NavigableSupport.getContent(NavigableSupport.groovy:45)
at geb.content.NavigableSupport.propertyMissing(NavigableSupport.groovy:129)
at Page.groovy:25)
{noformat}

I tested a couple different ways to solve this exception, and one that has worked well thus far (stopped NoSuchElementExceptions in 9 runs of 179 tests) is to add a wait into the root html element parsing in BrowserBackedNavigatorFactory.

{noformat}
Navigator getBase() {
WebDriverWait wait = new WebDriverWait(browser.driver, 10)

WebElement rootHtmlElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("html")))

createFromWebElements(Collections.singletonList(rootHtmlElement))

}
{noformat}

Notes on the implementation:

Config value to enable/disable the timeout

Config value for the timeout value

Wrap the exception that Selenium throws if the timeout is reached

@geb-bot
geb-bot commented Nov 27, 2013

Originally posted by Craig Atkinson.

It looks like I don't have the Jira permissions to assign this ticket to myself, but if it helps track who's working on what, feel free to assign this ticket to me. Thanks!

@geb-bot
geb-bot commented Jan 2, 2014

Originally posted by Marcin Erdmann.

There's a pull request for this here: geb/geb#54

@geb-bot
geb-bot commented Jun 12, 2014

Resolved

@geb-bot geb-bot added the New feature label Apr 12, 2015
@erdi erdi was assigned by geb-bot Apr 12, 2015
@geb-bot geb-bot added this to the 0.9.3 milestone Apr 12, 2015
@geb-bot geb-bot closed this Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment