Stale element exception?

48 views
Skip to first unread message

Sean Corfield

unread,
Aug 19, 2015, 2:08:44 PM8/19/15
to clj-we...@googlegroups.com
I’m getting this exception fairly consistently on one of my tests when I have New Relic enabled but not when I disable New Relic. If I run the test via the REPL (with New Relic enabled), it works. Any suggestions for mitigating / avoiding this? It’s on a call to (text "li.signin") which should always be present in the page (the test is that a request for /home redirects to / with a locale in the URL, hence we need to test for a string in a specific language). I’m on 0.7.2 right now (I get this on 0.7.1 as well).

     [exec] ERROR in (seo-logged-out) (NativeConstructorAccessorImpl.java:-2)

     [exec] Uncaught exception, not in assertion.

     [exec] expected: nil

     [exec]   actual: org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up

     [exec] Command duration or timeout: 60.15 seconds

     [exec] For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html

     [exec] Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'

     [exec] System info: host: 'Sean-Corfields-iMac.local', ip: '10.0.0.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_31'

     [exec] Driver info: org.openqa.selenium.firefox.FirefoxDriver

     [exec] Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=32.0.3, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]

     [exec] Session ID: eeb39da3-4d29-934d-a0ff-fee53a134f1f

     [exec]  at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)

     [exec]     sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)

     [exec]     sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)

     [exec]     java.lang.reflect.Constructor.newInstance (Constructor.java:408)

     [exec]     org.openqa.selenium.remote.ErrorHandler.createThrowable (ErrorHandler.java:206)

     [exec]     org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (ErrorHandler.java:158)

     [exec]     org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:595)

     [exec]     org.openqa.selenium.remote.RemoteWebElement.execute (RemoteWebElement.java:273)

     [exec]     org.openqa.selenium.remote.RemoteWebElement.getText (RemoteWebElement.java:157)

     [exec]     sun.reflect.GeneratedMethodAccessor8.invoke (:-1)

     [exec]     sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

     [exec]     java.lang.reflect.Method.invoke (Method.java:483)

     [exec]     clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)

     [exec]     clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:313)

     [exec]     clj_webdriver.core$eval3184$fn__3226.invoke (core_element.clj:107)

     [exec]     clj_webdriver.core$eval2349$fn__2429$G__2340__2434.invoke (core.clj:93)

     [exec]     clj_webdriver.taxi$text.invoke (taxi.clj:1104)

     [exec]     clj_webdriver.taxi$text.invoke (taxi.clj:1102)

     [exec]     worldsingles.test.seo_logged_out/fn (seo_logged_out.clj:16)


Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Mayank Jain

unread,
Aug 19, 2015, 2:15:21 PM8/19/15
to clj-we...@googlegroups.com
I have seen such errors if I hold onto the reference of that object and pass that object for click, wait etc.
Its possible that the the node has changed and hence its not able to find the old object.
Is there a wait check before you do text on it?
Are you sure you are directly looking up that element by css selector?


--
You received this message because you are subscribed to the Google Groups "clj-webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-webdrive...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

semperos

unread,
Aug 19, 2015, 2:15:51 PM8/19/15
to clj-webdriver
I've not personally encountered stale element exceptions on my end. I'd take a look at where and how the stale element exception gets raised (http://github.com/seleniumHQ/selenium) and see if the kind of bytecode instrumentation New Relic would be performing could possibly impact the logic used to determine if an element is stale.

Barring the discovery of a deterministic solution, you might try a (refresh) call...

-Daniel

Sean Corfield

unread,
Aug 19, 2015, 2:31:44 PM8/19/15
to clj-we...@googlegroups.com
Mayank Jain wrote on Wednesday, August 19, 2015 at 11:14 AM:
I have seen such errors if I hold onto the reference of that object and pass that object for click, wait etc.

It’s a simple call to (text "li.signin") — it works almost 100% of the time without New Relic in the mix but fails pretty consistently with New Relic running. So I don’t think New Relic is specifically to blame but it exacerbates the problem. We’ve never managed to repro the (very rare) occasional failures of this particular test so it’s an interesting situation that it fails consistently with New Relic running in the app under test.

Its possible that the the node has changed and hence its not able to find the old object.

The test is around a redirect that is actually done via JS so it’s possible WebDriver gets the old page and hasn’t refreshed after the redirect. So, yes, it’s possible that the node changed.

Is there a wait check before you do text on it?

I’ve tried it with/without a short sleep. I will try Daniel’s suggestion of (refresh) — if it fails, followed by another call to (text "li.signin").

Are you sure you are directly looking up that element by css selector?

See above: just (text "li.signin")

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Reply all
Reply to author
Forward
0 new messages