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

"TypeError: can't access dead object" if the frame is removed from under us #614

Closed
barancev opened this issue Apr 7, 2017 · 26 comments
Closed
Assignees

Comments

@barancev
Copy link

barancev commented Apr 7, 2017

Firefox Version

55.0a1 (2017-04-06) (64-bit)
geckodriver 0.15

Platform

Windows 7

Steps to reproduce

Java Selenium test FrameSwitchingTest.testShouldNotBeAbleToDoAnythingTheFrameIsDeletedFromUnderUs, the main part is:

    driver.switchTo().frame("iframe1");
    driver.findElement(By.id("killIframe")).click(); // deletes the current frame
    driver.findElement(By.id("killIframe")); // try to do something

NoSuchFrameException is expected, but the trace is:

1491588306354	webdriver::server	DEBUG	Got request POST AbsolutePath("/session/b64f0a3e-5caf-485a-a2fa-e18fd8817b2e/element")
1491588306354	webdriver::command	DEBUG	Got request body {"value":"#killIframe","using":"css selector"}
1491588306354	geckodriver::marionette	DEBUG	→ 66:[0,8,"findElement",{"using":"css selector","value":"#killIframe"}]
1491588306356	Marionette	TRACE	0 -> [0,8,"findElement",{"using":"css selector","value":"#killIframe"}]
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: can't access dead object
Full stack: find_@chrome://marionette/content/element.js:290:7
element.find/</findElements<@chrome://marionette/content/element.js:256:17
evalFn@chrome://marionette/content/wait.js:70:7
wait.until/<@chrome://marionette/content/wait.js:84:5
wait.until@chrome://marionette/content/wait.js:65:10
element.find/<@chrome://marionette/content/element.js:255:24
element.find@chrome://marionette/content/element.js:254:10
findElementContent@chrome://marionette/content/listener.js:1199:18
TaskImpl_run@resource://gre/modules/Task.jsm:319:42
TaskImpl@resource://gre/modules/Task.jsm:277:3
asyncFunction@resource://gre/modules/Task.jsm:252:14
Task_spawn@resource://gre/modules/Task.jsm:166:12
TaskImpl_handleResultValue@resource://gre/modules/Task.jsm:389:16
TaskImpl_run@resource://gre/modules/Task.jsm:327:15
TaskImpl@resource://gre/modules/Task.jsm:277:3
asyncFunction@resource://gre/modules/Task.jsm:252:14
Task_spawn@resource://gre/modules/Task.jsm:166:12
dispatch/<@chrome://marionette/content/listener.js:363:15

*************************
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: can't access dead object
Full stack: find_@chrome://marionette/content/element.js:290:7
element.find/</findElements<@chrome://marionette/content/element.js:256:17
evalFn@chrome://marionette/content/wait.js:70:7
wait.until/<@chrome://marionette/content/wait.js:84:5
wait.until@chrome://marionette/content/wait.js:65:10
element.find/<@chrome://marionette/content/element.js:255:24
element.find@chrome://marionette/content/element.js:254:10
findElementContent@chrome://marionette/content/listener.js:1199:18
TaskImpl_run@resource://gre/modules/Task.jsm:319:42
TaskImpl@resource://gre/modules/Task.jsm:277:3
asyncFunction@resource://gre/modules/Task.jsm:252:14
Task_spawn@resource://gre/modules/Task.jsm:166:12
TaskImpl_handleResultValue@resource://gre/modules/Task.jsm:389:16
TaskImpl_run@resource://gre/modules/Task.jsm:327:15
TaskImpl@resource://gre/modules/Task.jsm:277:3
asyncFunction@resource://gre/modules/Task.jsm:252:14
Task_spawn@resource://gre/modules/Task.jsm:166:12
dispatch/<@chrome://marionette/content/listener.js:363:15

*************************
1491588306360	Marionette	TRACE	0 <- [1,8,{"error":"webdriver error","message":"TypeError: can't access dead object","stacktrace":"find_@chrome://marionette/content/element.js:290:7\nelement.find/</findElements<@chrome://marionette/content/element.js:256:17\nevalFn@chrome://marionette/content/wait.js:70:7\nwait.until/<@chrome://marionette/content/wait.js:84:5\nwait.until@chrome://marionette/content/wait.js:65:10\nelement.find/<@chrome://marionette/content/element.js:255:24\nelement.find@chrome://marionette/content/element.js:254:10\nfindElementContent@chrome://marionette/content/listener.js:1199:18\nTaskImpl_run@resource://gre/modules/Task.jsm:319:42\nTaskImpl@resource://gre/modules/Task.jsm:277:3\nasyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\nTaskImpl_handleResultValue@resource://gre/modules/Task.jsm:389:16\nTaskImpl_run@resource://gre/modules/Task.jsm:327:15\nTaskImpl@resource://gre/modules/Task.jsm:277:3\nasyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\ndispatch/<@chrome://marionette/content/listener.js:363:15\n"},null]
1491588306360	geckodriver::marionette	DEBUG	← [1,8,{"error":"webdriver error","message":"TypeError: can't access dead object","stacktrace":"find_@chrome://marionette/content/element.js:290:7\nelement.find/</findElements<@chrome://marionette/content/element.js:256:17\nevalFn@chrome://marionette/content/wait.js:70:7\nwait.until/<@chrome://marionette/content/wait.js:84:5\nwait.until@chrome://marionette/content/wait.js:65:10\nelement.find/<@chrome://marionette/content/element.js:255:24\nelement.find@chrome://marionette/content/element.js:254:10\nfindElementContent@chrome://marionette/content/listener.js:1199:18\nTaskImpl_run@resource://gre/modules/Task.jsm:319:42\nTaskImpl@resource://gre/modules/Task.jsm:277:3\nasyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\nTaskImpl_handleResultValue@resource://gre/modules/Task.jsm:389:16\nTaskImpl_run@resource://gre/modules/Task.jsm:327:15\nTaskImpl@resource://gre/modules/Task.jsm:277:3\nasyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\ndispatch/<@chrome://marionette/content/listener.js:363:15\n"},null]
1491588306361	webdriver::server	DEBUG	Returning status InternalServerError
1491588306361	webdriver::server	DEBUG	Returning body {"value":{"error":"unknown error","message":"TypeError: can't access dead object","stacktrace":"stack backtrace:\n   0:           0x61f07f - <no info>\n   1:           0x61fe59 - <no info>\n   2:           0x43b0b5 - <no info>\n   3:           0x420313 - <no info>\n   4:           0x408307 - <no info>\n   5:           0x6750f9 - <no info>\n   6:           0x416877 - <no info>\n   7:           0x66ed53 - <no info>\n   8:         0x76da59cd - BaseThreadInitThunk"}}
@whimboo
Copy link
Collaborator

whimboo commented Apr 12, 2017

We currently only check for valid chrome windows, but not for content windows. So it means that you have to wait for https://bugzilla.mozilla.org/show_bug.cgi?id=1349861 being fixed.

@KPKA
Copy link

KPKA commented Apr 20, 2017

I fixed this problem with Driver.SwitchTo().DefaultContent();. (see: http://stackoverflow.com/questions/16396767/firefox-bug-with-selenium-cant-access-dead-object)
Found a Mozilla blog entry about this topic: https://blog.mozilla.org/addons/2012/09/12/what-does-cant-access-dead-object-mean/

@whimboo
Copy link
Collaborator

whimboo commented Apr 20, 2017

You fixed it because you explicitly switched away from the non-existent browsing context. With the upcoming fix in Marionette the failure you would see without your change, would only change to a NoSuchWindowError.

So it means leave your change in and you will be fine.

@lautorres
Copy link

FF 53.0 The Driver.SwitchTo().DefaultContent(); doesn't work for me :(
And the original issue still persist

@psycho23
Copy link

psycho23 commented May 7, 2017

Firefox 53.0:


A coding exception was thrown and uncaught in a Task.

Full message: TypeError: can't access dead object
Full stack: onIteratorRangeFound@resource://gre/modules/Finder.jsm:457:1
this.FinderIterator._findAllRanges<@resource://gre/modules/FinderIterator.jsm:496:11
TaskImpl_run@resource://gre/modules/Task.jsm:319:42


@whimboo
Copy link
Collaborator

whimboo commented May 8, 2017

Me too comments are currently not helpful. We know about this problem. To track the status of the Marionette integration please watch https://bugzilla.mozilla.org/show_bug.cgi?id=1349861, or wait until this issue gets closed. Thanks.

@andreastt
Copy link
Contributor

andreastt commented May 8, 2017 via email

@ramendik
Copy link

ramendik commented May 17, 2017

I have encountered a use case where the expected fix (changing to NoSuchWindowError) is not enough.

I am using WebDriverWait to wait for a Dojo UI to render. I switch to the content frame and then wait for a certain element to become clickable; I know it is only drawn and enabled at the end of the rendering. But while the rendering is happening, the content frame gets reloaded fully - yet the frame with the name still exists.

I would expect the wait to succeed, and it does with Chrome, but it fails with Geckodriver. I have a workaround (thanks to Florent B. on stackoverflow), a custom condition which switches frame every time. But I think the standard wait should still work.

Details: http://stackoverflow.com/questions/44005034/cant-access-dead-object-in-geckodriver/

@whimboo
Copy link
Collaborator

whimboo commented May 18, 2017

I think that I will work on https://bugzilla.mozilla.org/show_bug.cgi?id=1349861 next, just to make the error message webdriver conform.

@ramendik it would help us if you can provide a minimized testcase for this, and also attach a trace level log. As best file a new issue for this, which would be dependent on this. Thanks.

@ramendik
Copy link

ramendik commented May 18, 2017

@whimboo the code I use is at the stackoverflow link. But unfortunately, the Web UI I am testing is not public and I am not able to reimplement the problem - just don't know how to code the Web page. The page would need to have a content frame and to refresh it dynamically.

I can try to collect a trace log in my existing environment if that would help.

@whimboo
Copy link
Collaborator

whimboo commented May 18, 2017

Please do so, and really file a new issue given that it is different to this one. Thanks.

@alexlazarciuc
Copy link

Hi folks,

Just wondering if this was fixed? I'm using geckodriver 0.21.0 and Firefox 61 and in some cases after using a frame - the page gets reloaded, I get the "System.InvalidOperationException : TypeError: can't access dead object" error?

Thanks!

@whimboo
Copy link
Collaborator

whimboo commented Jul 24, 2018

@alexlazarciuc do you have a code example which works publicly and we can use to reproduce it? Thanks.

@kathagcam
Copy link

kathagcam commented Sep 11, 2018

Was this resolved? I'm able to reproduce this issue.
async switchToFrame(by: webdriver.By) {
return this.driver.switchTo().frame(this.driver.findElement(by));
}
"geckodriver": "^1.12.2",
"selenium-webdriver": "^4.0.0-alpha.1"
"@types/selenium-webdriver": "^3.0.8",
Firefox: 62.0 (64-bit)
Is there a known workaround I can use to avoid this issue?

@whimboo
Copy link
Collaborator

whimboo commented Sep 11, 2018

@kathagcam can you please provide a trace log? As it looks like the referenced bug in Bugzilla is fixed but the problem might still be existent. Please see https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html in how to create one. Then please upload it as attachment to this issue. Thanks.

@barancev
Copy link
Author

The issue is still actual, here is the trace log of the Java test mentioned in the oiriginal post.
trace.log

@whimboo
Copy link
Collaborator

whimboo commented Sep 11, 2018

@barancev do you also have the corresponding HTML snippet which this test uses? That would be helpful.

@barancev
Copy link
Author

https://github.com/SeleniumHQ/selenium/tree/master/common/src/web/frame_switching_tests
files deletingFrame.html and deletingFrame_iframe.html

@whimboo
Copy link
Collaborator

whimboo commented Sep 21, 2018

Thanks! I can reproduce and filed https://bugzilla.mozilla.org/show_bug.cgi?id=1493108 to get the missing "browser context" check implemented.

@russlamb
Copy link

russlamb commented Nov 5, 2018

Driver.SwitchTo().DefaultContent() before the offending command worked for me. thanks.

@hardikantala
Copy link

Hi Guys, Driver.SwitchTo().DefaultContent() is not working in FF 72.0.2. Is there any workaround here

@neekhu
Copy link

neekhu commented Apr 22, 2020

This worked for me:

WebUI.delay(2)
WebUI.switchToWindowIndex(0)
WebUI.delay(5)
WebUI.switchToDefaultContent()

@komireddy407
Copy link

any update on this?
issue with firefox only

@whimboo
Copy link
Collaborator

whimboo commented Sep 21, 2020

This is fixed now in Firefox 82, which will become beta soon. It would be great if anyone can verify that. Thanks a lot.

@whimboo whimboo closed this as completed Sep 21, 2020
@whimboo whimboo self-assigned this Sep 21, 2020
@jackblk
Copy link

jackblk commented Nov 24, 2020

@whimboo I tested on Firefox 83 (release version), geckodriver 0.28.0, MacOS 11.0.1, Selenium 3.141.0.

In Firefox 81 & geckodriver 0.27.0, I can still reproduce the bug. Seems like the bug is partly fixed in Firefox 83? If I don't switch to default content before switching to iframe, it will give me another error:

response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"Browsing context has been discarded","stacktra...ome://marionette/content/server.js:241:9\\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:504:20\\n"}}'}
selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded

I assume that we need more fix?

For now, i use driver.switch_to.default_content() in selenium python to avoid this problem.

@whimboo
Copy link
Collaborator

whimboo commented Nov 25, 2020

@jackblk please file a new issue for that, and please attach a trace log and if possible a minimized test case. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests