Skip to content
This repository has been archived by the owner. It is now read-only.

WebDriver and Firefox 4+: this.getWindow() is null #1438

Closed
lukeis opened this issue Mar 2, 2016 · 39 comments
Closed

WebDriver and Firefox 4+: this.getWindow() is null #1438

lukeis opened this issue Mar 2, 2016 · 39 comments

Comments

@lukeis
Copy link
Member

@lukeis lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 1438

I am seeing this error when running a selenium 2 FF4 test with the latest version of
the selenium-webdriver gem (0.1.4):


Selenium::WebDriver::Error::UnhandledError in 'Test that the Readiness Cold States
are set properly before(:all)'
this.getWindow() is null
System info: os.name: 'Windows Server 2008', os.arch: 'x86', os.version: '6.0', java.version:
'1.6.0_21'
Driver info: driver.version: unknown (org.openqa.selenium.remote.ErrorHandler$UnknownServerException)
[remote server] <anonymous class>(file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/session.js):178:in
`<anonymous method>'
[remote server] <anonymous class>(file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/firefoxDriver.js):395:in
`<anonymous method>'
[remote server] <anonymous class>(file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/firefoxDriver.js):499:in
`<anonymous method>'
[remote server] <anonymous class>(file://C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js):306:in
`<anonymous method>'
[remote server] <anonymous class>(resource:/fxdriver/modules/utils.js):8434:in `<anonymous
method>'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/response.rb:45:in
`assert_ok'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/response.rb:15:in
`initialize'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/http/common.rb:59:in
`new'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/http/common.rb:59:in
`create_response'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/http/default.rb:56:in
`request'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/http/common.rb:40:in
`call'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/bridge.rb:476:in
`raw_execute'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/bridge.rb:454:in
`execute'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/bridge.rb:424:in
`find_element_by'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/remote/bridge.rb:242:in
`findElementByCssSelector'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/common/search_context.rb:44:in
`send'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/common/search_context.rb:44:in
`find_element'
/Users/danny/projects/knewdle/trunk/test/selenium/rspec_platform/shared_functions_platform.rb:115:in
`wait_for_the_element'
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.1.4/lib/selenium/webdriver/common/wait.rb:36:in
`until'
/Users/danny/projects/knewdle/trunk/test/selenium/rspec_platform/shared_functions_platform.rb:114:in
`wait_for_the_element'
/Users/danny/projects/knewdle/trunk/test/selenium/rspec_platform/shared_functions_platform.rb:73:in
`login_to_site'
./test/selenium/rspec_platform/platform_specs/dashboard_cold_states_spec.rb:12:
script/spec:5:


Here is a dump from the server:

21:50:19.985 INFO - Executing: [find element: By.selector: #whitelabel-work-selector
at URL: /session/1300830600208/element)
21:50:35.974 WARN - Exception thrown
org.openqa.selenium.WebDriverException: this.getWindow() is null
System info: os.name: 'Windows Server 2008', os.arch: 'x86', os.version: '6.0', java.version:
'1.6.0_21'
Driver info: driver.version: EventFiringWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:131)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:105)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:409)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:192)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:257)
    at org.openqa.selenium.By$8.findElement(By.java:281)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:95)
    at $Proxy1.findElement(Unknown Source)
    at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:171)
    at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:49)
    at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: this.getWindow()
is null
System info: os.name: 'Windows Server 2008', os.arch: 'x86', os.version: '6.0', java.version:
'1.6.0_21'
Driver info: driver.version: unknown
    at <anonymous class>.<anonymous method>(file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/session.js:178)
    at <anonymous class>.<anonymous method>(file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/firefoxDriver.js:395)
    at <anonymous class>.<anonymous method>(file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/firefoxDriver.js:499)
    at <anonymous class>.<anonymous method>(file:///C:/Users/chef/AppData/Local/Temp/anonymous9203632030004100842webdriver-profile/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:306)
    at <anonymous class>.<anonymous method>(resource://fxdriver/modules/utils.js:8434)
21:50:35.981 WARN - Exception: this.getWindow() is null
System info: os.name: 'Windows Server 2008', os.arch: 'x86', os.version: '6.0', java.version:
'1.6.0_21'
Driver info: driver.version: unknown
21:50:37.091 INFO - Command request: captureScreenshot[c:\job_assets\shot_4.png, ]
on session 1300830600208
21:50:37.332 INFO - Got result: OK on session 1300830600208
21:50:37.338 INFO - Executing: [delete session: 1300830600208] at URL: /session/1300830600208)
21:50:38.550 INFO - Done: /session/1300830600208
21:50:38.557 INFO - Command request: shutDownSeleniumServer[, ] on session 1300830600208
21:50:38.557 INFO - Shutdown command received
21:50:38.558 INFO - Got result: OK on session 1300830600208
21:50:38.558 INFO - initiating shutdown
21:50:39.061 INFO - Shutting down...
21:50:39.062 INFO - Stopping Acceptor ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4443]

Reported by qablogmbox on 2011-03-22 21:57:07

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Note this same test works fine in FF 3.6.

Thanks

Reported by qablogmbox on 2011-03-22 21:58:46

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Reported by jari.bakken on 2011-03-23 14:52:05

  • Labels added: Component-WebDriver, Browser-Firefox
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Can you provide a minimal test case consisting of the Ruby, HTML and Javascript (or
URL if it's publicly accessible) required to reproduce this problem?

Reported by jari.bakken on 2011-03-23 15:03:37

  • Status changed: NeedsClarification
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I've received a test case that reproduces the problem, which the reporter doesn't want
to share publicly. Emailed to SImon and Eran.

Reported by jari.bakken on 2011-03-24 15:50:14

  • Status changed: Accepted
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I've managed to reproduce this on a public site. Should help us get a fix in shortly.

Reported by jari.bakken on 2011-04-05 18:10:06

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Simon tells me this is an issue in Firefox, related to inner vs outer windows [1] and
that we should file a bug with Mozilla.

For now you should be able to work around the problem by doing this before the command
that raises the error:

  driver.switch_to.default_content 

[1] https://developer.mozilla.org/en/Inner_and_outer_windows

Reported by jari.bakken on 2011-04-05 18:48:03

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Same issue. Thanks for the workaround.

Reported by werner%beroux.com@gtempaccount.com on 2011-04-12 05:48:10

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Hey Jari. Was this issue logged with the Mozilla folks?

Reported by qablogmbox on 2011-04-12 16:47:03

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Unfortunately not. I don't know the details of the problem well enough to actually write
up a good bug report, but others on the project do. I'll ping them.

Reported by jari.bakken on 2011-04-12 16:53:55

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 1576 has been merged into this issue.

Reported by jari.bakken on 2011-04-19 21:24:37

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Thanks for the tip, my issue (was a duplicate of this) is solved by this. FWIW call
switch_to_default_content() after each new URL.

Reported by charlie.clark@clark-consulting.eu on 2011-04-28 09:34:23

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Any word/progress with the Mozilla guys? 

Reported by qablogmbox on 2011-05-02 14:58:33

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Reported by jari.bakken on 2011-07-05 20:23:42

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 1988 has been merged into this issue.

Reported by jari.bakken on 2011-07-05 20:24:08

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Thanks for the tip (Comment 8). The workaround also works for my issue. (It was a duplicate.)

Reported by argrico on 2011-07-06 07:48:50

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

This is still happening for me in FF5--did a bug ever get filed with Mozilla?

Reported by stephen.haberman on 2011-07-14 19:53:54

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

It is awful to say as a committer, but I'm locking customers to FF 3.6.x because of
this outstanding issue.  

Reported by paul@hammant.org on 2011-07-15 20:33:01

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I could really do with a repeatable test case for this. I'm not running into it very
often at all, which makes it harder to fix properly.

Reported by simonstewart@google.com on 2011-07-17 17:39:17

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I have emailed Simon a repro script. 

Reported by qablogmbox on 2011-07-18 22:53:43

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 2176 has been merged into this issue.

Reported by jari.bakken on 2011-08-02 15:10:31

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Hi All,

I 'm getting the similar exception

Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 10
seconds
Build info: version: '2.3.0', revision: '13158', time: '2011-08-01 18:13:39'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.34.9-69.fc13.i686',
java.version: '1.6.0_21'
Driver info: driver.version: unknown
    at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:220)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:186)
    at chancler.chancler.SWDriver.main(SWDriver.java:36)
Please suggest me where and what exactly i have to apply for work around.

Thanks,
Narendra Gollapilli.

Reported by naren.nasa on 2011-08-08 21:44:36

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

jari.bakken, can you send us the test that reproduces this issue on the public site?

Reported by leo.lathspell on 2011-09-07 16:12:13

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I reproduced this against Twitter's login page in April. Not sure if it still works,
but here's the script

https://gist.github.com/904503

Commenting line 138 would reproduce perhaps 50% of the time back then (unfortunately
I'm unable to try it out right now). 

Reported by jari.bakken on 2011-09-07 17:09:56

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Tried the script again - unfortunately not able to reproduce against the Twitter login
page any more.

Reported by jari.bakken on 2011-09-11 20:40:38

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I could reproduce it with the attached script, using ubuntu 11.04 and selenium 2.6 on
the site http://one.ubuntu.com

I get the error:

'Invalid server response; no status: %s' % body)
AssertionError: Invalid server response; no status: {"name":"findElement","sessionId":"4c587be8-668e-4e4d-ad0c-47154f69ee21","value":{"message":"this.getWindow()
is null"

Adding the switch_to_default_content makes it work.

Reported by leo.lathspell on 2011-09-20 04:53:42


- _Attachment: [seleniumnullwindow.py](https://storage.googleapis.com/google-code-attachments/selenium/issue-1438/comment-30/seleniumnullwindow.py)_
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I'm getting this same "Invalid server response; no status" error using Firefox 6.0.2
on Windows 7; python 2.7, latest version of Selenium (selenium-2.7.0.tar.gz, via pip).
 The "driver.switch_to_default_content()" workaround did work for me.

What can I do to help get the Firefox driver fixed?  There's another bug in the Firefox
driver which should be fixed at the same time:  When calling driver.find_element_by_class_name("some_class_name"),
it will click in the spot where that element was before the "this site requires additional
plugins to view properly".  However, the bar at the top moves the page down slightly,
so the click action occurs just above the selected item.  If I put a time.sleep(20)
in there and manually close the notification bar at the top, it clicks in the correct
location.

Based on the stacktrace I got, it looks like the issue is related to the JSON data.
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line
172, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line
525, in find_element
    {'using': by, 'value': value})['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line
142, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py",
line 256, in execute
    return self._request(url, method=command_info[0], data=data)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py",
line 307, in _request
    'Invalid server response; no status: %s' % body)
AssertionError: Invalid server response; no status:

Reported by JohnLongfellow@mail.com on 2011-09-30 23:32:57

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

This can easily be triggered with a meta refresh (at least on OS X / Firefox 7):

  https://gist.github.com/191860e67dbb22a40bec

Happens around 40 iterations for me.

Reported by jari.bakken on 2011-10-03 20:07:40

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 2544 has been merged into this issue.

Reported by barancev on 2011-10-06 18:25:03

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Yes the problem in issue 2544 showed itself to be this.getWindow() is null. And it is
still pretty regular in Firefox 7. I used the workaround with logg.driver.switchTo().defaultContent();
and it works, you must add it here and there though so a solution would be appreciated,
perhaps in cooperation with the Firefox people. 
I also saw another thing, you can't use selenium.selenium.waitForPageToLoad(3000);
You get a nullpointer and I add thread.sleep(3000) instead.

/BrittB

Reported by brbe24 on 2011-10-08 03:02:48

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 2638 has been merged into this issue.

Reported by jari.bakken on 2011-10-11 20:32:13

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I've seen an exception happening there:
http://code.google.com/p/selenium/source/browse/trunk/javascript/firefox-driver/extension/components/firefoxDriver.js#81

All the code is trying to do there is determine whether to expect a load event, based
on the current and future URLs. If session.getWindow() is null, it's safe to assume
there is no URL loaded so a load event is expected.
Assigning to myself - I'll have a go at fixing this.

Reported by eran.mes on 2011-10-19 11:32:50

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

I have a fix that should solve this for at least the provided test cases in comment
30 and 32. Will commit shortly. 

Reported by jari.bakken on 2011-11-13 20:33:26

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

This issue was closed by revision r14712.

Reported by jari.bakken on 2011-11-13 20:58:49

  • Status changed: Fixed
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

If anyone's still seeing this issue after 2.13, please let us know.

Reported by jari.bakken on 2011-11-13 21:00:30

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 1856 has been merged into this issue.

Reported by jari.bakken on 2011-11-14 10:26:27

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Issue 3029 has been merged into this issue.

Reported by barancev on 2012-05-05 13:57:31

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Reported by jari.bakken on 2015-02-26 23:01:20

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Reported by eran.mes on 2015-02-27 10:29:57

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:12:31

  • Labels added: Restrict-AddIssueComment-Commit
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant