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

Calling maximize_window causes script to hang #703

Closed
2 tasks done
davehunt opened this issue Apr 28, 2017 · 16 comments
Closed
2 tasks done

Calling maximize_window causes script to hang #703

davehunt opened this issue Apr 28, 2017 · 16 comments
Assignees

Comments

@davehunt
Copy link
Member

davehunt commented Apr 28, 2017

In order to help us efficiently investigate your issue, please provide the following information:

Firefox Version

55.0a1 (2017-04-28) (64-bit)

Platform

macOS 10.12.4

Other

geckodriver 0.16.1
selenium 3.4.1 (Python)

Steps to reproduce -

Please provide a description of how to reproduce the problem, including the following essential elements:

  • A minimal HTML file (or files) that can be used to reproduce the issue (this should not be your production site, unless you are unable to isolate the problem, but a page containing only the elements required to observe the problem).

No HTML necessary to reproduce bug.

  • A trace level log from a geckodriver session that demonstrates the problem using the minimal example file. Note: this is not the same as a selenium log.
1493398038115	geckodriver	INFO	Listening on 127.0.0.1:65472
1493398039262	geckodriver::marionette	INFO	Starting browser /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin with args ["-marionette"]
1493398039265	geckodriver::marionette	TRACE	  connection attempt 0/600
1493398039370	geckodriver::marionette	TRACE	  connection attempt 1/600
1493398039474	geckodriver::marionette	TRACE	  connection attempt 2/600
1493398039575	geckodriver::marionette	TRACE	  connection attempt 3/600
1493398039677	geckodriver::marionette	TRACE	  connection attempt 4/600
1493398039779	geckodriver::marionette	TRACE	  connection attempt 5/600
1493398039883	geckodriver::marionette	TRACE	  connection attempt 6/600
1493398039988	geckodriver::marionette	TRACE	  connection attempt 7/600
1493398040092	geckodriver::marionette	TRACE	  connection attempt 8/600
1493398040199	geckodriver::marionette	TRACE	  connection attempt 9/600
1493398040300	geckodriver::marionette	TRACE	  connection attempt 10/600
1493398040408	geckodriver::marionette	TRACE	  connection attempt 11/600
1493398040511	geckodriver::marionette	TRACE	  connection attempt 12/600
1493398040617	geckodriver::marionette	TRACE	  connection attempt 13/600
1493398040726	geckodriver::marionette	TRACE	  connection attempt 14/600
1493398040829	geckodriver::marionette	TRACE	  connection attempt 15/600
1493398040934	geckodriver::marionette	TRACE	  connection attempt 16/600
1493398041042	geckodriver::marionette	TRACE	  connection attempt 17/600
1493398041146	geckodriver::marionette	TRACE	  connection attempt 18/600
1493398041258	geckodriver::marionette	TRACE	  connection attempt 19/600
1493398041362	geckodriver::marionette	TRACE	  connection attempt 20/600
1493398041477	geckodriver::marionette	TRACE	  connection attempt 21/600
1493398041587	geckodriver::marionette	TRACE	  connection attempt 22/600
2017-04-28 17:47:21.648 plugin-container[36041:20355739] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xa32b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-04-28 17:47:21.651 plugin-container[36041:20355739] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xa703, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1493398041699	geckodriver::marionette	TRACE	  connection attempt 23/600
1493398041812	geckodriver::marionette	TRACE	  connection attempt 24/600
1493398041917	geckodriver::marionette	TRACE	  connection attempt 25/600
1493398041957	Marionette	DEBUG	Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1493398041957	Marionette	DEBUG	Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1493398041957	Marionette	INFO	Listening on port 65485
1493398042020	geckodriver::marionette	DEBUG	Connected to Marionette on localhost:65485
1493398042057	Marionette	DEBUG	Accepted connection 0 from 127.0.0.1:49186
1493398042076	geckodriver::marionette	TRACE	← {"applicationType":"gecko","marionetteProtocol":3}
1493398042076	geckodriver::marionette	TRACE	→ 163:[0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1493398042094	Marionette	TRACE	0 -> [0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1493398042104	Marionette	CONFIG	Matched capabilities: {"browserName":"firefox","browserVersion":"55.0a1","platformName":"darwin","platformVersion":"16.5.0","pageLoadStrategy":"normal","acceptInsecureCerts":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":36040,"moz:profile":"/var/folders/3y/wrsgzz095jb2dg7vk9wnd42r0000gn/T/rust_mozprofile.4UflLjm2E8Bf","moz:accessibilityChecks":false}
1493398042104	Marionette	WARN	TLS certificate errors will be ignored for this session
1493398042152	Marionette	DEBUG	loaded listener.js
1493398042163	Marionette	TRACE	0 <- [1,1,null,{"sessionId":"9cab90fa-c62f-6947-af5f-1e40506ec751","capabilities":{"browserName":"firefox","browserVersion":"55.0a1","platformName":"darwin","platformVersion":"16.5.0","pageLoadStrategy":"normal","acceptInsecureCerts":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":36040,"moz:profile":"/var/folders/3y/wrsgzz095jb2dg7vk9wnd42r0000gn/T/rust_mozprofile.4UflLjm2E8Bf","moz:accessibilityChecks":false}}]
1493398042164	geckodriver::marionette	TRACE	← [1,1,null,{"sessionId":"9cab90fa-c62f-6947-af5f-1e40506ec751","capabilities":{"browserName":"firefox","browserVersion":"55.0a1","platformName":"darwin","platformVersion":"16.5.0","pageLoadStrategy":"normal","acceptInsecureCerts":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":36040,"moz:profile":"/var/folders/3y/wrsgzz095jb2dg7vk9wnd42r0000gn/T/rust_mozprofile.4UflLjm2E8Bf","moz:accessibilityChecks":false}}]
1493398042164	webdriver::server	DEBUG	← 200 OK {"value": {"sessionId":"9cab90fa-c62f-6947-af5f-1e40506ec751","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"55.0a1","moz:accessibilityChecks":false,"moz:processID":36040,"moz:profile":"/var/folders/3y/wrsgzz095jb2dg7vk9wnd42r0000gn/T/rust_mozprofile.4UflLjm2E8Bf","pageLoadStrategy":"normal","platformName":"darwin","platformVersion":"16.5.0","rotatable":false,"specificationLevel":0,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
1493398042167	webdriver::server	DEBUG	→ POST /session/9cab90fa-c62f-6947-af5f-1e40506ec751/window/maximize {"windowHandle": "current", "sessionId": "9cab90fa-c62f-6947-af5f-1e40506ec751"}
1493398042168	geckodriver::marionette	TRACE	→ 25:[0,2,"maximizeWindow",{}]
1493398042171	Marionette	TRACE	0 -> [0,2,"maximizeWindow",{}]

The following script causes a hang until the window is manually resized:

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options

o = Options()
o.log.level = 'trace'
o.binary = '/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin'

f = Firefox(firefox_options=o)
f.maximize_window()
assert True

After manually resizing the window, the script continues and the following additional lines are written to the log file:

1493398075972	Marionette	TRACE	0 <- [1,2,null,{"x":-1657,"y":-791,"width":1288,"height":777}]
1493398075973	geckodriver::marionette	TRACE	← [1,2,null,{"x":-1657,"y":-791,"width":1288,"height":777}]
1493398075973	webdriver::server	DEBUG	← 200 OK {"value": {}}
1493398076027	Marionette	DEBUG	Closed connection 0

Note that the window is already maximized when maximize_window is called. If I add a sleep and reduce the window size, the script completes as expected. I'm also using two screens, and moving the window to the second screen (where it is no longer taking up the full height/width) before called maximize_window the script still fails as described.

@jeanpylone
Copy link

jeanpylone commented May 2, 2017

Hello,

I have the same problem with Firefox 53.0, geckodriver 0.16.1 and selenium 3.4.0, either on Windows 10 or on Linux Mint.
I use browser.driver.manage().window().setSize() for my tests. Doing some tests with with wireshark, I saw that setSize works the first time (sending POST /wd/hub/session/xxx/window/current/size and POST /session/xxx/window/rect at the same time), and indeed the browser size changes. But in a second test I do a setSize with the exact same size and here all the following requests never get answer (including POST /wd/hub/session/xxx/window/current/size and POST /session/xxx/window/rect).

Edit: using an ugly hack to not set the exact same size each time I use setSize, my test suite seem to work well, confirming that setting the same size is the root of the issue.

@andreastt
Copy link
Contributor

I suspect that this was fixed as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1357878, which is available in Firefox 55 or greater. It would be great if someone could try that out and confirm it works!

@andreastt
Copy link
Contributor

@jeanpylone Setting the window’s size is fundamentally different to maximising: they are two separate endpoints and commands.

We had an issue recently where calling Set Window Rect/setSize twice with the same arguments caused Marionette to never return a response, see #643. That particular problem was also patched in https://bugzilla.mozilla.org/show_bug.cgi?id=1357878.

@davehunt
Copy link
Member Author

davehunt commented May 4, 2017

@andreastt I am still seeing this with 55.0a1 (2017-05-03) (64-bit)

@andreastt
Copy link
Contributor

@davehunt That is odd.

What I see locally when the window isn’t maximized:

>>> m.maximize_window()
1493894089253	Marionette	TRACE	2 -> [0,3,"maximizeWindow",{}]
1493894089317	Marionette	TRACE	2 <- [1,3,null,{"x":0,"y":0,"width":1912,"height":1072}]
{u'y': 0, u'x': 0, u'height': 1072, u'width': 1912}
>>> m.maximize_window()
1493894098990	Marionette	TRACE	2 -> [0,4,"maximizeWindow",{}]
1493894099034	Marionette	TRACE	2 <- [1,4,null,{"x":24,"y":48,"width":1280,"height":972}]
{u'y': 48, u'x': 24, u'height': 972, u'width': 1280}

When I maximize the window manually first, then call m.maximize_window, it hangs as you described.

The implementation of Maximize Window looks like this:

  yield new Promise(resolve => {
    win.addEventListener("resize", resolve, {once: true});

    if (win.windowState == win.STATE_MAXIMIZED) {
      win.restore();
    } else {
      win.maximize();
    }
  });

That means that win.windowState isn’t being set to the win.STATE_MAXIMIZED when the window is manually made to fit the full window. My guess is that win.restore/win.maximize contains a check to not run the operation if the window dimensions match the destination, and that this is why the promise is failing.

@andreastt andreastt reopened this May 4, 2017
@andreastt
Copy link
Contributor

On further investigation, when the window is manually resized to fit the screen, the code above is supposed to restore the window to its former size. Its former size is the size of the screen, and the window state consequently reports it as maximized. This is why the promise fails to resolve.

@whimboo
Copy link
Collaborator

whimboo commented May 8, 2017

So what happens if the window has the size of the screen when not being maximized, and then you do a maximize()? The dimensions shouldn't change, right? So no resize event should be send.

@andreastt
Copy link
Contributor

andreastt commented May 8, 2017 via email

minusnine added a commit to tebeka/selenium that referenced this issue May 10, 2017
minusnine added a commit to tebeka/selenium that referenced this issue May 10, 2017
@FelipeJK
Copy link

FelipeJK commented May 12, 2017

Hi all,
I am getting "org.openqa.selenium.WebDriverException: getWindowRect" just calling driver..manage().window().getSize();..

Does someone else also get this issue?

Some log info:
494620707802	webdriver::server	DEBUG	→ GET /session/cce999bf-940d-48bd-b4a5-b5f5e2e7a45c/window/rect 
1494620707802	geckodriver::marionette	TRACE	→ 27:[0,1300,"getWindowRect",{}]
1494620707804	Marionette	TRACE	conn0 -> [0,1300,"getWindowRect",{}]
1494620707804	Marionette	TRACE	conn0 <- [1,1300,{"error":"unknown command","message":"getWindowRect","stacktrace":"WebDriverError@chrome://marionette/content/error.js:200:5\nUnknownCommandError@chrome://marionette/content/error.js:444:5\nDispatcher.prototype.execute/req<@chrome://marionette/content/dispatcher.js:121:13\nTaskImpl_run@resource://gre/modules/Task.jsm:319:42\nTaskImpl@resource://gre/modules/Task.jsm:277:3\ncreateAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\nDispatcher.prototype.execute@chrome://marionette/content/dispatcher.js:118:13\nDispatcher.prototype.onPacket@chrome://marionette/content/dispatcher.js:89:5\nDebuggerTransport.prototype._onJSONObjectReady/<@chrome://marionette/content/server.js -> resource://devtools/shared/transport/transport.js:483:11\nexports.makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:101:14\nexports.makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:101:14\n"},null]
1494620707805	geckodriver::marionette	TRACE	� [1,1300,{"error":"unknown command","message":"getWindowRect","stacktrace":"WebDriverError@chrome://marionette/content/error.js:200:5\nUnknownCommandError@chrome://marionette/content/error.js:444:5\nDispatcher.prototype.execute/req<@chrome://marionette/content/dispatcher.js:121:13\nTaskImpl_run@resource://gre/modules/Task.jsm:319:42\nTaskImpl@resource://gre/modules/Task.jsm:277:3\ncreateAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:252:14\nTask_spawn@resource://gre/modules/Task.jsm:166:12\nDispatcher.prototype.execute@chrome://marionette/content/dispatcher.js:118:13\nDispatcher.prototype.onPacket@chrome://marionette/content/dispatcher.js:89:5\nDebuggerTransport.prototype._onJSONObjectReady/<@chrome://marionette/content/server.js -> resource://devtools/shared/transport/transport.js:483:11\nexports.makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:101:14\nexports.makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:101:14\n"},null]
1494620707806	webdriver::server	DEBUG	� 404 Not Found {"value":{"error":"unknown error","message":"getWindowRect","stacktrace":"stack backtrace:\n   0:           0x489f6f - <no info>\n   1:           0x48ad59 - <no info>\n   2:           0x43a15d - <no info>\n   3:           0x4474c9 - <no info>\n   4:           0x445208 - <no info>\n   5:           0x41ddb1 - <no info>\n   6:           0x4091c7 - <no info>\n   7:           0x6bc939 - <no info>\n   8:           0x415a19 - <no info>\n   9:           0x6b6e43 - <no info>\n  10:     0x7ffb90128364 - BaseThreadInitThunk"}}
mai 12, 2017 5:25:07 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown error' (500 expected)
JavaScript error: resource://app/modules/WindowsJumpLists.jsm, line 403: NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIJumpListShortcut.app]

Thanks

@andreastt
Copy link
Contributor

@FelipeJK Which Firefox version are you using? Your error isn’t related to this issue, as you can see from your stacktrace. It is complaining about the the fact that the getWindowRect command doesn’t exist in the Marionette server, so I’m guessing your Firefox version is pretty old?

@FelipeJK
Copy link

@andreastt I am using official Firefox 52 ESR, build 52.1.1.

@andreastt
Copy link
Contributor

@FelipeJK According to https://bugzilla.mozilla.org/show_bug.cgi?id=1347589, the Marionette setWindowRect command is only available in Firefox 53 or greater. Sorry for this.

@andreastt
Copy link
Contributor

I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1375185 to fix this in Marionette.

@whimboo
Copy link
Collaborator

whimboo commented Nov 14, 2018

@davehunt do you still see this problem with latest Nightly?

@davehunt
Copy link
Member Author

I can no longer replicate this with latest geckodriver and Firefox Nightly.

@lock
Copy link

lock bot commented Aug 16, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants