Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaleElementReferenceException emanating from Shutterbug.shootElement #87

Closed
roboaks opened this issue Dec 31, 2020 · 9 comments
Closed
Assignees

Comments

@roboaks
Copy link

roboaks commented Dec 31, 2020

We are using shutterbug v1.2 to take full page screen shots of a scrollable div (using the feature we collaborated on a few months back).

Here is the full stack trace:

EXCEPTION_:org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=87.0.4280.88)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'GitHub', ip: '172.31.36.180', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.88, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\ITSUser\AppData\Lo...}, goog:chromeOptions: {debuggerAddress: localhost:51006}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 7a9d209c3eba5b47e04ee2ea727c221c
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_191]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.8.0_191]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.8.0_191]
at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.8.0_191]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) [SeleniumFixture-all.jar]
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:489) [SeleniumFixture-all.jar]
at com.assertthat.selenium_shutterbug.utils.web.Browser.executeJsScript(Browser.java:668) [SeleniumFixture-all.jar]
at com.assertthat.selenium_shutterbug.utils.web.Browser.getElementCurrentScrollX(Browser.java:599) [SeleniumFixture-all.jar]
at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullElementScreenshotScroll(Browser.java:360) [SeleniumFixture-all.jar]
at com.assertthat.selenium_shutterbug.core.Shutterbug.shootElement(Shutterbug.java:246) [SeleniumFixture-all.jar]
at com.its.itap.fixtures.selenium.helpers.Screenshot._saveScreenshot(Screenshot.java:510) [SeleniumFixture-all.jar]
at com.its.itap.fixtures.selenium.helpers.Screenshot.saveScreenshot(Screenshot.java:657) [SeleniumFixture-all.jar]
at com.its.itap.fixtures.selenium.SeleniumFixture.saveScreenshot(SeleniumFixture.java:2322) [SeleniumFixture-all.jar]
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) [n/a]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_191]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_191]
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81) [fitnesse-standalone.jar]
at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:57) [fitnesse-standalone.jar]
at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:38) [fitnesse-standalone.jar]
at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:72) [fitnesse-standalone.jar]
at fitnesse.slim.LibraryMethodExecutor.execute(LibraryMethodExecutor.java:18) [fitnesse-standalone.jar]
at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:126) [fitnesse-standalone.jar]
at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:104) [fitnesse-standalone.jar]
at fitnesse.slim.instructions.CallInstruction.executeInternal(CallInstruction.java:35) [fitnesse-standalone.jar]
at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29) [fitnesse-standalone.jar]
at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49) [fitnesse-standalone.jar]
at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43) [fitnesse-standalone.jar]
at fitnesse.slim.ListExecutor.execute(ListExecutor.java:83) [fitnesse-standalone.jar]
at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:87) [fitnesse-standalone.jar]
at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:80) [fitnesse-standalone.jar]
at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:58) [fitnesse-standalone.jar]
at fitnesse.slim.SlimServer.serve(SlimServer.java:43) [fitnesse-standalone.jar]
at fitnesse.slim.SlimService.handle(SlimService.java:186) [fitnesse-standalone.jar]
at fitnesse.slim.SlimService.acceptOne(SlimService.java:194) [fitnesse-standalone.jar]
at fitnesse.slim.SlimService.accept(SlimService.java:156) [fitnesse-standalone.jar]
at fitnesse.slim.SlimService.startWithFactory(SlimService.java:77) [fitnesse-standalone.jar]
at fitnesse.slim.SlimService.main(SlimService.java:57) [fitnesse-standalone.jar]
@glibas glibas self-assigned this Jan 3, 2021
@glibas
Copy link
Member

glibas commented Jan 3, 2021

Hi @roboaks ,

Have you got a reproducible example?

@roboaks
Copy link
Author

roboaks commented Jan 4, 2021

Unfortunately, no. The issue only seems to occur in one development environment so far--though it appears consistently. In my experience, because StaleElementReferenceExceptions can be timing related, it's not super unusual for them to manifest in an environment-specific and/or intermittent manner.

Can you tell which element is becoming stale and is it possible to add a retry loop (e.g. see this post)?

@glibas
Copy link
Member

glibas commented Jan 4, 2021

Try 1.3-SNAPSHOT version and use Shutterbug.shootElement(WebDriver driver, By element, CaptureElement capture) method passing By locator which will dynamically find the element, hopefully fixing StaleElementReferenceException

@roboaks
Copy link
Author

roboaks commented Jan 4, 2021

Could not resolve: com.assertthat:selenium-shutterbug:1.3-SNAPSHOT

I am using the jcenter repository and the following Gradle statement: implementation ('com.assertthat:selenium-shutterbug:1.3-SNAPSHOT'). This is the exact same configuration that successfully resolves for v1.2.

@glibas
Copy link
Member

glibas commented Jan 4, 2021

You need to add snapshots repo url to make it resolve. Something like below

	repositories {
		jcenter()
		maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
	}

@roboaks
Copy link
Author

roboaks commented Jan 4, 2021

That worked. I have updated our Selenium fixture accordingly and am waiting for feedback from the developer.

Glib, thank you so much for the quick response.

@roboaks
Copy link
Author

roboaks commented Jan 5, 2021

According to the developer that seems to have fixed the problem! Thanks so much for the quick turnaround.

Will you be posting a new release to jcenter?

@glibas
Copy link
Member

glibas commented Jan 7, 2021

Hi Rob,
I'm going to release the change today/tomorrow

@glibas
Copy link
Member

glibas commented Jan 8, 2021

Released under v1.3. Will be available after a little while

@glibas glibas closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants