Hi. I`ve created a demo project which I hope will help to reproduce the bug on your side.
You just need to import it to IDE and set paths to the chromedriver\phantomjs in your system.
https://drive.google.com/file/d/0BxvxRApe_YizdUgxYmNiZTlZQ1k/view?usp=sharing
In the demo test story tries to check visibility of different elements(present and absent in DOM). While playing around please see how implicitly wait in webdriver and pageobject is changing, how timeoutstack is filling and resetTimeout method works.
I`ve got the following log on y side:
[pool-1-thread-1] INFO HomePage - Checking if existent element visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 260
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 5000 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Checking if non-existent element visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 5054
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 5000 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Checking if non-existent element currently visible (isCurrentlyVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 56
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 5000 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Checking if non-existent element 2 visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 22
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 5000 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Restoring WebDriver Timeout manually by getDriver().manage().timeouts().implicitlyWait
[pool-1-thread-1] INFO HomePage - Checking if non-existent element 2 visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 5049
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 5000 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Setting implicitly wait to 0 by setImplicitTimeout()
[pool-1-thread-1] INFO HomePage - Checking if non-existent element 2 currently visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 16
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 0 MILLISECONDS
[pool-1-thread-1] INFO HomePage - Restoring WebDriver Timeout manually by resetImplicitTimeout()
[pool-1-thread-1] INFO HomePage - Checking if non-existent element 2 currently visible (isVisible)
[pool-1-thread-1] INFO HomePage - TOOK: 10
[pool-1-thread-1] INFO HomePage - Current Implicitly timeout in Page Object: 0 MILLISECONDS
Thank You.
The problem was suggested to be resolved in 1.0.49 version but there is some issue left.
As I can see the problem have not been fixed fully by the committed changes. Each method, after isCurrentlyVisible() method, is performed with 0 implicitlywait timeout despite the fact that I can see non-zero value of implicitlytimeout wait in PageObject. WebDriverFactory, WebElementImpl classes during test execution. Also I discovered that everything works as expected if we place resetImplicitTimeout() method after isCurrentlyVisible().
So the code below works incorrectly:
searchButton.
searchButton.isCurrentlyVisible();
nonExistentInDomElement.isVisible()
//the timeout for the last method is unexpectedly 0
So the code below works correctly but needs excessive method:
searchButton.
searchButton.isCurrentlyVisible();
resetImplicitTimeout();
nonExistentInDomElement.isVisible()
//the timeout for the last method is default implicitlytimeout set in properties
Please try to do additional investigation in the scope of the issue.
--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def "Element loading times should not be affected by isCurrently* methods"() {given: "The element may appear in DOM after 20 seconds"environmentVariables.setProperty("webdriver.timeouts.implicitlywait","20000")page = openTestPageUsing("firefox")when: "we should be able to access some element on the page"page.country.isCurrentlyVisible()then: "we should be able to wait up to 20 seconds for an element that is not in DOM jet"page.fieldDoesNotExist.isDisplayed()}
def "You can override the implicit wait during test execution"() {
given: "The #slow-loader field takes 3 seconds to load"
page = openTestPageUsing("phantomjs")
when: "We override the implicit timeout to allow the slow-loader field to load"
page.setImplicitTimeout(100, SECONDS)
then: "we should be able to access the slow-loader field"
page.firstElementItem.isVisible()
and: "we can reset the driver timeouts to the default value once we are done"
page.resetImplicitTimeout()
and:
page.fieldDoesNotExist.isVisible()
and:
page.driver.currentImplicitTimeout.in(SECONDS) == 2
Also all waits are slow. For example waitForAbsenceOf("#someId.someclass") takes a few seconds (it uses findElements behind the scenes). Have you noticed this problem?
--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public boolean elementIsDisplayed(final By byElementCriteria) {
try {
List<WebElement> matchingElements = driver.findElements(byElementCriteria);
for (WebElement webElement : matchingElements) {
WebElementFacade element = WebElementFacadeImpl.wrapWebElement(driver, webElement, 100);
if (element.isCurrentlyVisible()) {
return true;
}
} return false;
} catch (NoSuchElementException noSuchElement) {
LOGGER.trace("No such element " + noSuchElement);
return false;
} catch (StaleElementReferenceException se) {
LOGGER.trace("Element no longer attached to the DOM " + se);
return false;
}
}(Session info: chrome=44.0.2403.125)
(Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961),platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: '6wbuildbot.local', ip: '10.40.6.215', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/g1/66c6b4qn08d9y0q90fk5v_f00000gs/T/.org.chromium.Chromium.MKdwQC}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=44.0.2403.125, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 506e07f033bd55a2dfdd85bce5942836
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:310)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.isElementUsable(SmartAjaxElementLocator.java:129)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator$SlowLoadingElement.isLoaded(SmartAjaxElementLocator.java:217)
at org.openqa.selenium.support.ui.SlowLoadableComponent.get(SlowLoadableComponent.java:59)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.ajaxFindElement(SmartAjaxElementLocator.java:138)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.findElement(SmartAjaxElementLocator.java:93)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy16.isEnabled(Unknown Source)
at net.serenitybdd.core.pages.WebElementFacadeImpl.isEnabled(WebElementFacadeImpl.java:539)
----------
Not sure why it's getting times out in 9 milisecons even when serenity.properties has entry
webdriver.wait.for.timeout = 30000
webdriver.timeouts.implicitlywait = 10000
Command duration or timeout: 24 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: '6wbuildbot.local', ip: '10.40.6.215', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/g1/66c6b4qn08d9y0q90fk5v_f00000gs/T/.org.chromium.Chromium.9nlH2A}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=44.0.2403.130, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: f9894c203d10993260562d1628ae28e6
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:310)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.isElementUsable(SmartAjaxElementLocator.java:129)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator$SlowLoadingElement.isLoaded(SmartAjaxElementLocator.java:217)
at org.openqa.selenium.support.ui.SlowLoadableComponent.get(SlowLoadableComponent.java:59)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.ajaxFindElement(SmartAjaxElementLocator.java:138)
at net.thucydides.core.annotations.locators.SmartAjaxElementLocator.findElement(SmartAjaxElementLocator.java:93)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy17.isEnabled(Unknown Source)
at net.serenitybdd.core.pages.WebElementFacadeImpl.isEnabled(WebElementFacadeImpl.java:539)
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=44.0.2403.130)
(Driver info: chromedriver=2.17.340128 (994135a3538dd99439ef22cea8a9b098e00d8eb4),platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 34 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: '6wbuildbot.local', ip: '10.40.6.215', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/g1/66c6b4qn08d9y0q90fk5v_f00000gs/T/.org.chromium.Chromium.uLa8Wr}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=44.0.2403.130, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 8d525c4139c06160f3bf53917a1d35dc
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
at org.openqa.selenium.remote.RemoteWebElement.isEnabled(RemoteWebElement.java:143)
...