SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

IDE/Core: can't access dead object error #4761

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 4761

Record the following. After step 6 it stops and errors appear in the Error console.

1. Start Selenium IDE and go to Chapter 1 on http://book.theautomatedtester.co.uk.

2. Click on the Click this link to launch another window link. This will launch
a pop-up window.

3. Assert the text on the page. We do this by right-clicking and selecting assertText.

4. Go back to the parent window and click on the link to launch the second
pop-up window.

5. Verify the text on the page.

6. Move to the first pop-up window and close it using the close link. As before,
be aware of clickAndWait instead of click.

7. Move to the second pop-up window and close it using the close link.

8. Move back to the parent window and verify an element on that page.

It appears the compartmentalization of Firefox's JS objects is breaking a reference
we had to the window.

Timestamp: 11/11/2012 21:55:49
Error: TypeError: can't access dead object
Source File: chrome://selenium-ide/content/editor.js
Line: 702

Reported by david.burns@theautomatedtester.co.uk on 2012-11-11 22:03:00

lukeis commented 8 years ago
Additional information: this is a FF16 specific issue, it can be observed when you run
RC tests on FF16 (go test-rc).

Reported by barancev on 2012-11-13 08:47:57

lukeis commented 8 years ago
relevant post with many Se users complaining of the same / similar problem in IDE 
http://blog.mozilla.org/addons/2012/09/12/what-does-cant-access-dead-object-mean/

Reported by luke.semerau on 2013-01-08 05:14:43

lukeis commented 8 years ago
Issue 4983 has been merged into this issue.

Reported by luke.semerau on 2013-01-08 05:15:03

lukeis commented 8 years ago
Issue 4710 has been merged into this issue.

Reported by barancev on 2013-01-29 22:47:16

lukeis commented 8 years ago
Seeing very similar behaviour with Selenium IDE 1.10.0 installed to Firefox 18.0.2 on
Windows. Anyone know of a workaround to this?

Best regards, 
George

Reported by george.harley on 2013-02-15 18:28:49

lukeis commented 8 years ago
The attached file results in:
    [info] Executing: |open | /Eng/MarketData/Indices/MarketCap/Pages/IndexHistoryData.aspx?Action=1&addTab=&IndexId=142
| |
    [info] Executing: |click | id=history1 | |
    [info] Executing: |clickAndWait | xpath=(//input[@value='Display Data'])[2] | |
    [info] Executing: |click | css=td.GreenTextBtn | |
    [info] Executing: |click | link=TSV | |
    [warn] Opening window '_blank', which is not a real window name. Randomizing target
to be: selenium_blank35973
    [info] Executing: |waitForPopUp | _blank | 30000 |
    [error] can't access dead object 

FF 18.0.2 on an up-to-date Windows 7 (64 bit)

Reported by mguttman4 on 2013-02-17 18:01:37


lukeis commented 8 years ago

Reported by barancev on 2013-02-17 18:17:27

lukeis commented 8 years ago
 I am using Selenium Server 2.30 and FF 18.0.1 and am also encountering the "Can't access
dead object" error while waiting for page after a button click.  

Reported by Locri4n on 2013-02-21 16:40:00

lukeis commented 8 years ago
when will the fix be available? 

Reported by rafalfusik on 2013-02-21 17:35:02

lukeis commented 8 years ago
Rolling back to Firefox 12.0 fixes the issue

Reported by idealboy89 on 2013-03-14 12:15:50

lukeis commented 8 years ago
Issue 5364 has been merged into this issue.

Reported by barancev on 2013-03-23 13:36:37

lukeis commented 8 years ago
I'm using java selenium client 2.31.0 and FF 18.0.2 (webdriver) on windows 7 and I'm
also run into this bug from time to time. No popup windows however, it's just a click
on a link that sometimes causes the following error:

Error: can't access dead object
Source: file:///C:/Users/user/AppData/Local/Temp/anonymous8144928914942444972webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js
Line: 8226

driver_component.js:
8216         e.setUserData("webdriver-evaluate-code", null, null);
8217         a.send()
8218       }
8219     };
8220     e.addEventListener("webdriver-evaluate-response", j, !0);
8221     b = e.createEvent("Events");
8222     b.initEvent("webdriver-evaluate", !0, !1);
8223     e.dispatchEvent(b)
8224   };
8225   d.runWhenTrue(function() {
8226     return!!e.body
8227   }, function() {
8228     if(!e.getUserData("webdriver-evaluate-attached")) {
8229       var a = e.createElement("script");
8230       a.setAttribute("type", "text/javascript");
8231       a.innerHTML = FirefoxDriver.listenerScript;
8232       e.body.appendChild(a);
8233       a.parentNode.removeChild(a)
8234     }
8235     d.runWhenTrue(l, k, 1E4, p)
8236   }, 1E4, function() {

Reported by discordia.primula on 2013-03-27 01:51:29

lukeis commented 8 years ago
--> Rolling back to Firefox 12.0 fixes the issue
Yes, Its working with FF14 too, but i would like to upgrade firefox to the latest.
Anyone know any workaround or a temp fix for this issue?

Reported by rafalfusik on 2013-03-27 09:03:13

lukeis commented 8 years ago
A quote from the Firefox "Addons" blog (https://blog.mozilla.org/addons/2012/09/12/what-does-cant-access-dead-object-mean/):

Firefox 15 introduced a major improvement in memory usage, by disallowing add-ons to
keep references to DOM objects after their parent document was destroyed. This eliminates
the most common cause of memory leaks in add-ons, and should reduce memory consumption
for many users.

    snip ******* snip

This means that Firefox did the right thing and prevented the add-on from holding on
to this object. However, it also means that the add-on probably won’t work correctly.

Please note the last sentence...

FYI!

Reported by mguttman4 on 2013-04-15 19:26:23

lukeis commented 8 years ago
Still a problem in the latest release of webdriver. Any workarounds for this other than
resurrecting ancient Firefox versions?

Reported by hippyjim on 2013-05-12 12:10:15

lukeis commented 8 years ago
i'd like to know it too @hippy

Reported by rafalfusik on 2013-05-12 21:26:26

lukeis commented 8 years ago
Any progress on this?

Reported by zepedro.correia on 2013-05-24 12:30:57

lukeis commented 8 years ago
Anyone got any further? I'm looking really stupid to a lot of people who say that testing
is a pointless waste of time.

From my guess, the problem is that selenium needs to be able to rescan the document
and pick up the fact that the dom object it had cached with an id/selector of X has
been replaced with another one, that has the same id/selector. It looks like it caches
the reference to it - hence Firefox saying no. At least, that's what my research suggests
- this is making any test impossible to run, I can't believe such a major breaking
problem that affects every way I try to use selenium to test this page - PHPUnit, IDE,
htmlsuite - hasn't even had an acknowledgment yet - am I missing a fix somewhere else
that people are keeping to themselves?

Reported by hippyjim on 2013-06-25 13:56:52

lukeis commented 8 years ago
Ok, more info - it even happening if I open a page.

So my theory is totally wrong. It can't even abort the current page and open a new
one. This is a nightmare. Anyone got any ideas?

PHPUnit commands:

        $this->waitForTextPresent("Company Info");
        $this->assertElementPresent("id=Name");
        $this->assertEquals("! selenium test customer", $this->getValue("id=Name"));
        $this->assertElementPresent("id=Address1");
        $this->assertEquals("1 The Street", $this->getValue("id=Address1"));
        $contactId = $this->getValue('id=AccountNo'); 
        $this->open('/APPURL/contacts/edit/cus/' . $contactId);

------------

Console output:

16:09:49.181 INFO - Command request: getExpression[id=Name, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.188 INFO - Got result: OK,id=Name on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.190 INFO - Command request: getExpression[id=Name, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.195 INFO - Got result: OK,id=Name on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.197 INFO - Command request: isElementPresent[id=Name, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.203 INFO - Got result: OK,true on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.205 INFO - Command request: getExpression[id=Name, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.210 INFO - Got result: OK,id=Name on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.213 INFO - Command request: getValue[id=Name, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.222 INFO - Got result: OK,! selenium test customer on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.226 INFO - Command request: getExpression[id=Address1, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.231 INFO - Got result: OK,id=Address1 on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.232 INFO - Command request: getExpression[id=Address1, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.236 INFO - Got result: OK,id=Address1 on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.237 INFO - Command request: isElementPresent[id=Address1, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.240 INFO - Got result: OK,true on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.242 INFO - Command request: getExpression[id=Address1, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.246 INFO - Got result: OK,id=Address1 on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.247 INFO - Command request: getValue[id=Address1, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.251 INFO - Got result: OK,1 The Street on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.252 INFO - Command request: getExpression[id=AccountNo, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.256 INFO - Got result: OK,id=AccountNo on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.257 INFO - Command request: getValue[id=AccountNo, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.262 INFO - Got result: OK,CUSTID on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.263 INFO - Command request: getExpression[/APPURL/contacts/edit/cus/CUSTID,
] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.267 INFO - Got result: OK,/APPURL/contacts/edit/cus/CUSTID on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.268 INFO - Command request: open[/APPURL/contacts/edit/cus/CUSTID, ] on session
88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.271 INFO - Got result: ERROR: Command execution failure. Please search the
user group at https://groups.google.com/forum/#!forum/selenium-users for error details
from the log window.  The error message is: can't access dead object on session 88ffae4ba2df4c5eaa1a333b77ae6ee6
16:09:49.273 INFO - Command request: testComplete[, ] on session 88ffae4ba2df4c5eaa1a333b77ae6ee6

Reported by hippyjim on 2013-06-25 15:28:36

lukeis commented 8 years ago
I may have found a workaround for this bug; it's worked for me so far as well as the
reproduction steps in the original post. Hopefully it helps others who, like me, were
using an old version of FF.

In the latest IDE release (2.2.0), replace editor.js:707 with a try/catch to handle
the "dead object" error and set the lastWindow to null. (There may be reasons for some
of you to hang onto that old window object, but I haven't experienced any problems
so far.)

704 704     Editor.prototype.addCommand = function(command,target,value,window,insertBeforeLastCommand)
{
705 705         this.log.debug("addCommand: command=" + command + ", target=" + target
+ ", value=" + value + " window.name=" + window.name);
706 706         if (this.lastWindow) {
707     -           this.log.debug("window.name=" + window.name + ", lastWindow.name=" +
this.lastWindow.name);
707 +           try {
708 +               this.log.debug("window.name=" + window.name + ", lastWindow.name="
+ this.lastWindow.name);
709 +           } catch (e) {
710 +               this.lastWindow = null;
711 +               this.log.debug("window.name=" + window.name);
712 +           }
708 713         } else {
709 714             this.log.debug("window.name=" + window.name);
710 715         }

Reported by bradjh83 on 2013-07-16 05:20:38

lukeis commented 8 years ago
any progress and a proper fix for it ?

Reported by rafalfusik on 2013-07-16 08:32:31

lukeis commented 8 years ago
Where is the editor.js  path?

Reported by israel.ortegaf on 2013-07-17 11:39:47

lukeis commented 8 years ago
Here is editor.js:
https://code.google.com/p/selenium/source/browse/ide/main/src/content/editor.js#707

Unpack the installed extension's XPI into the same extension directory, remove any
filename extension (so it's called something like "{...}"), rename the original XPI
file, modify the "{...}"/chrome/content/editor.js file, and close Firefox, your changes
will take effect when FF is reloaded.

Reported by bradley@decipherinc.com on 2013-07-17 17:53:21

lukeis commented 8 years ago
This issue was closed by revision 1d675b47e8bd.

Reported by Samit.Badle on 2013-07-27 11:29:41

lukeis commented 8 years ago
Hi,

My commit fixes the Selenium IDE issue while recording tests as provided in the steps
to reproduce by David. The fix will be available in Selenium IDE 2.3.0 (next release).

This does not mean that there are no other dead object issues in Selenium IDE or Selenium
Core. The changes in Firefox would affect all interactions with multiple windows or
frames. Please raise a new issue to report them with tests to reproduce.

Cheers,
Samit Badle
Selenium IDE Maintainer
Twitter: @samitbadle
Blog: http://blog.reallysimplethoughts.com/

Reported by Samit.Badle on 2013-07-27 11:41:12

lukeis commented 8 years ago
If you're willing to build your own copy of Firefox from the source, you can comment
out lines 907 and 908 of jswrapper.cpp...

These two:

                e.removeFront();
                NukeCrossCompartmentWrapper(cx, wobj);

That fixed all Dead Object errors for me. A pain I know. The Firefox people should
have left us some way to switch this on and off for automated testing.

Reported by dlunday on 2014-01-15 22:59:45

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:16:19