title: "Can't access dead object" in geckodriver
body: <p>I am using Selenium 3.4 with Java. With Chrome, everything works fine. But I need to use Firefox, and there something breaks.</p>
  
  <p>I am automating the testing of a Dojo UI, and need to wait while the Dojo UI does a lot of rendering. So here is what I do, and it works just fine in Chrome. Note that an implicit wait of 20 seconds is normally set in my code.</p>
  
  <pre><code>driver.switchTo().defaultContent();
  driver.switchTo().frame(driver.findElement(By.id("contentframe"))); // relying on implicit wait 
  driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
  (new WebDriverWait(driver, 120)).
       until(ExpectedConditions.elementToBeClickable(By.id("some_id")));
  </code></pre>
  
  <p>I have simplified the code so you don't see how the implicit wait is set back to 20 seconds. When the problem happens, it does not get there, anyway. The WebDriverWait causes an exception. The exception says <code>TypeError: can't access dead object</code></p>
  
  <p>There is a corresponding message from inside the wait:</p>
  
  <pre><code>May 16, 2017 3:36:11 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
  WARNING: WebDriverException thrown by findElement(By.id: 
  some_id)
  org.openqa.selenium.WebDriverException: TypeError: can't access dead object
  </code></pre>
  
  <p>There is also some JavaScript error output, apparently, by geckodriver:</p>
  
  <pre><code>JavaScript error: chrome://marionette/content/listener.js, line 1555: TypeError: can't access dead object
  *************************
  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:284:7
  element.find/&lt;/findElements&lt;@chrome://marionette/content/element.js:255:15
  implicitlyWaitFor/&lt;/elementSearch@chrome://marionette/content/element.js:600:15
  implicitlyWaitFor/&lt;@chrome://marionette/content/element.js:627:5
  implicitlyWaitFor@chrome://marionette/content/element.js:593:10
  element.find/&lt;@chrome://marionette/content/element.js:254:24
  element.find@chrome://marionette/content/element.js:253:10
  findElementsContent@chrome://marionette/content/listener.js:1314:19
  TaskImpl_run@resource://gre/modules/Task.jsm:319:42
  TaskImpl@resource://gre/modules/Task.jsm:277:3
  createAsyncFunction/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
  createAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:252:14
  Task_spawn@resource://gre/modules/Task.jsm:166:12
  dispatch/&lt;@chrome://marionette/content/listener.js:186: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:284:7
  element.find/&lt;/findElements&lt;@chrome://marionette/content/element.js:255:15
  implicitlyWaitFor/&lt;/elementSearch@chrome://marionette/content/element.js:600:15
  implicitlyWaitFor/&lt;@chrome://marionette/content/element.js:627:5
  implicitlyWaitFor@chrome://marionette/content/element.js:593:10
  element.find/&lt;@chrome://marionette/content/element.js:254:24
  element.find@chrome://marionette/content/element.js:253:10
  findElementsContent@chrome://marionette/content/listener.js:1314:19
  TaskImpl_run@resource://gre/modules/Task.jsm:319:42
  TaskImpl@resource://gre/modules/Task.jsm:277:3
  createAsyncFunction/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
  createAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:252:14
  Task_spawn@resource://gre/modules/Task.jsm:166:12
  dispatch/&lt;@chrome://marionette/content/listener.js:186:15
  </code></pre>
  
  <p>Moreover, my automatic exception processing tries to take a screenshot but that fails with the very same error. The code line is:</p>
  
  <p><code>File snapshotTempFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
  </code>
  And this time the output from geckodriver is:</p>
  
  <pre><code>A coding exception was thrown and uncaught in a Task.
  
  Full message: TypeError: can't access dead object
  Full stack: capture.viewport@chrome://marionette/content/capture.js:65:7
  takeScreenshot@chrome://marionette/content/listener.js:1782:14
  dispatch/&lt;/req&lt;@chrome://marionette/content/listener.js:188:22
  TaskImpl_run@resource://gre/modules/Task.jsm:319:42
  TaskImpl@resource://gre/modules/Task.jsm:277:3
  createAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:252:14
  Task_spawn@resource://gre/modules/Task.jsm:166:12
  dispatch/&lt;@chrome://marionette/content/listener.js:186:15
  </code></pre>
  
  <p>So, can I do anything to make this work properly? And is this something I need to raise as a geckodriver bug?</p>
  
  <p>The only thing I could google out is this: <a href="https://github.com/mozilla/geckodriver/issues/614" rel="noreferrer">https://github.com/mozilla/geckodriver/issues/614</a> and the only proposed solution there is <code>driver.switchTo().defaultContent()</code> . This might fix my screenshot routine, but the element I am waiting for is inside the content frame, so I can't use this fix for the wait.</p>