没有显示器的情况下最大化硒窗?
目前,我在带有显卡和显示器的普通 PC 上本地运行 Selenium v4。但是,在生产中,我计划在没有监视器的服务器上运行 Selenium。
当我调用:driver.maximize() 时,它将浏览器最大化到与监视器/显示器相同的高度。当服务器没有显示器/监视器时,我在生产中会出现什么行为?最大化窗口有多大?
更新
我知道你可以在无头模式下运行 Selenium 但这不是我的问题。我的问题是,在这种情况下,Selenium/WebDriver 通常使用监视器/显示器的大小来最大化浏览器的大小,如何最大化浏览器的大小?它使用什么参考点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 调整和定位Windows WebDriver 规范的部分:
简而言之,在没有监视器的服务器上执行基于硒的测试。 ,在包含当前顶级浏览上下文的窗口上。这通常会将窗口增加到最大可用尺寸而无需全屏。
From the Resizing and positioning windows section of the WebDriver specification:
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.您可以尝试使用 get_window_size 来获取无头模式下最大化窗口的大小。
You could try using get_window_size to get the size of the maximized window in headless mode.