Currently, I'm running Selenium v4
locally on a normal PC with a graphics card and monitor. However, in production, I plan on running Selenium on a server that does not have a monitor.
When I call: driver.maximize()
it maximizes the browser the the same height as the monitor/display. What behavior can I expect in production when the server does not have a display/monitor? How big will it maximize the window?
Update
I know you could run Selenium in headless mode but this is not my question. My question is how does Selenium/WebDriver maximize the size of the browser in this case, when it normally uses the size of the monitor/display to do so? What reference point is it using?
CodePudding user response:
You could try using get_window_size to get the size of the maximized window in headless mode.
CodePudding user response:
From the Resizing and positioning windows section of the WebDriver specification:
To maximize the window, given an operating system level window with an associated top-level browsing context, run the implementation-specific steps to transition the operating system level window into the maximized window state. If the window manager supports window resizing but does not have a concept of window maximization, the window dimensions must be increased to the maximum available size permitted by the window manager for the current screen. Return when the window has completed the transition, or within an implementation-defined timeout.
In short, executing Selenium based tests on a server that does not have a monitor using driver.maximize()
, the command invokes the window manager-specific maximize operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the maximum available size without going full-screen.