Class Scroller
java.lang.Object
org.jenkinsci.test.acceptance.selenium.Scroller
- All Implemented Interfaces:
org.openqa.selenium.support.events.WebDriverListener
public class Scroller
extends Object
implements org.openqa.selenium.support.events.WebDriverListener
Automatically scrolls the element into view.
Especially in the configuration page, the floating DIVs at the top and the bottom of the pages can interfere with WebDriver trying to click the elements underneath it.
At least on Chrome (and possibly in other browsers), trying to interact with an element when it's below another element causes the following error:
Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 227.711 sec <<< FAILURE! - in plugins.AntPluginTest
autoInstallAnt(plugins.AntPluginTest) Time elapsed: 73.932 sec <<< ERROR!
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (506, 967). Other element would receive the click: <div class="bottom-sticker-inner">...</div>
(Session info: chrome=34.0.1847.116)
(Driver info: chromedriver=2.10.267518,platform=Linux 3.13.0-24-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61 milliseconds
Build info: version: '2.40.0', revision: '4c5c0568b004f67810ee41c459549aa4b09c651e', time: '2014-02-19 11:13:01'
System info: host: 'jglick-t520', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_55'
Session ID: 412a7b3ab0eb823da2cddd156e8d122c
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/tmp/.com.google.Chrome.3Xt0hp}, rotatable=false, locationContextEnabled=true, version=34.0.1847.116, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
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:573)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:331)
at com.sun.proxy.$Proxy33.click(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:344)
at org.jenkinsci.test.acceptance.po.CapybaraPortingLayer.clickButton(CapybaraPortingLayer.java:66)
at org.jenkinsci.test.acceptance.po.JenkinsConfig.addTool(JenkinsConfig.java:35)
at org.jenkinsci.test.acceptance.plugins.ant.AntInstallation.install(AntInstallation.java:37)
at plugins.AntPluginTest.autoInstallAnt(AntPluginTest.java:76)
This work around simply tries to scroll the element into a view before we interact with this.
Originally developed in Ruby version of selenium-tests in lib/jenkins/capybara.rb
.
- Author:
- ogondza, Kohsuke Kawaguchi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
beforeClear
(org.openqa.selenium.WebElement element) void
beforeClick
(org.openqa.selenium.WebElement element) void
beforeSendKeys
(org.openqa.selenium.WebElement element, CharSequence[] keysToSend) void
Sometimes sticky elements (elements that are fixed in position on the page, such as the bottom app bar), appear on top of other elements, making those elements inaccessible.void
scrollIntoView
(org.openqa.selenium.WebElement e) The framework is expected to take care of the correct scrolling.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openqa.selenium.support.events.WebDriverListener
afterAccept, afterActiveElement, afterAddCookie, afterAlert, afterAnyAlertCall, afterAnyCall, afterAnyNavigationCall, afterAnyOptionsCall, afterAnyTargetLocatorCall, afterAnyTimeoutsCall, afterAnyWebDriverCall, afterAnyWebElementCall, afterAnyWindowCall, afterBack, afterClear, afterClick, afterClose, afterDefaultContent, afterDeleteAllCookies, afterDeleteCookie, afterDeleteCookieNamed, afterDismiss, afterExecuteAsyncScript, afterExecuteScript, afterFindElement, afterFindElement, afterFindElements, afterFindElements, afterForward, afterFrame, afterFrame, afterFrame, afterFullscreen, afterGetAttribute, afterGetCookieNamed, afterGetCookies, afterGetCssValue, afterGetCurrentUrl, afterGetLocation, afterGetPageSource, afterGetPosition, afterGetSize, afterGetSize, afterGetTagName, afterGetText, afterGetText, afterGetTitle, afterGetWindowHandle, afterGetWindowHandles, afterImplicitlyWait, afterIsDisplayed, afterIsEnabled, afterIsSelected, afterMaximize, afterNewWindow, afterPageLoadTimeout, afterParentFrame, afterPerform, afterQuit, afterRefresh, afterResetInputState, afterSendKeys, afterSendKeys, afterSetPosition, afterSetScriptTimeout, afterSetSize, afterSubmit, afterTo, afterTo, afterWindow, beforeAccept, beforeActiveElement, beforeAddCookie, beforeAlert, beforeAnyAlertCall, beforeAnyCall, beforeAnyNavigationCall, beforeAnyOptionsCall, beforeAnyTargetLocatorCall, beforeAnyTimeoutsCall, beforeAnyWebDriverCall, beforeAnyWebElementCall, beforeAnyWindowCall, beforeBack, beforeClose, beforeDefaultContent, beforeDeleteAllCookies, beforeDeleteCookie, beforeDeleteCookieNamed, beforeDismiss, beforeExecuteAsyncScript, beforeExecuteScript, beforeFindElement, beforeFindElement, beforeFindElements, beforeFindElements, beforeForward, beforeFrame, beforeFrame, beforeFrame, beforeFullscreen, beforeGet, beforeGetAttribute, beforeGetCookieNamed, beforeGetCookies, beforeGetCssValue, beforeGetCurrentUrl, beforeGetLocation, beforeGetPageSource, beforeGetPosition, beforeGetSize, beforeGetSize, beforeGetTagName, beforeGetText, beforeGetText, beforeGetTitle, beforeGetWindowHandle, beforeGetWindowHandles, beforeImplicitlyWait, beforeIsDisplayed, beforeIsEnabled, beforeIsSelected, beforeMaximize, beforeNewWindow, beforePageLoadTimeout, beforeParentFrame, beforePerform, beforeQuit, beforeRefresh, beforeResetInputState, beforeSendKeys, beforeSetPosition, beforeSetScriptTimeout, beforeSetSize, beforeSubmit, beforeTo, beforeTo, beforeWindow, onError
-
Constructor Details
-
Scroller
public Scroller(org.openqa.selenium.WebDriver driver)
-
-
Method Details
-
beforeClick
public void beforeClick(org.openqa.selenium.WebElement element) - Specified by:
beforeClick
in interfaceorg.openqa.selenium.support.events.WebDriverListener
-
beforeSendKeys
- Specified by:
beforeSendKeys
in interfaceorg.openqa.selenium.support.events.WebDriverListener
-
beforeClear
public void beforeClear(org.openqa.selenium.WebElement element) - Specified by:
beforeClear
in interfaceorg.openqa.selenium.support.events.WebDriverListener
-
afterGet
- Specified by:
afterGet
in interfaceorg.openqa.selenium.support.events.WebDriverListener
-
disableStickyElements
public void disableStickyElements()Sometimes sticky elements (elements that are fixed in position on the page, such as the bottom app bar), appear on top of other elements, making those elements inaccessible. This method removes the sticky nature of these elements meaning that they'll no longer appear on top of other elements. -
scrollIntoView
public void scrollIntoView(org.openqa.selenium.WebElement e) The framework is expected to take care of the correct scrolling. When you are tempted to scroll from PageObjects or tests, there is likely a framework problem to be fixed.
-