Selenium WebDriver 可以在后台静默打开浏览器窗口吗? [英] Can Selenium WebDriver open browser windows silently in the background?
问题描述
我有一个 Selenium 测试套件,可以运行许多测试,并且在每个新测试中,它会在我打开的任何其他窗口之上打开一个浏览器窗口.在当地环境中工作时非常不和谐.有没有办法告诉 Selenium 或操作系统(Mac)在后台打开窗口?
I have a Selenium test suite that runs many tests and on each new test it opens a browser window on top of any other windows I have open. Very jarring while working in a local environment. Is there a way to tell Selenium or the OS (Mac) to open the windows in the background?
推荐答案
有几种方法,但不是简单的设置配置值".除非您投资于不适合所有人要求的无头浏览器,否则它有点像黑客:
There are a few ways, but it isn't a simple "set a configuration value". Unless you invest in a headless browser, which doesn't suit everyone's requirements, it is a little bit of a hack:
如何隐藏 Firefox 窗口 (Selenium WebDriver)?一个>
和
你可以'supposely',将一些参数传入Chrome,特别是:--no-startup-window
You can 'supposedly', pass in some parameters into Chrome, specifically: --no-startup-window
请注意,对于某些浏览器,尤其是 Internet Explorer,如果不让它在焦点上运行会影响您的测试.
Note that for some browsers, especially Internet Explorer, it will hurt your tests to not have it run in focus.
您还可以使用 AutoIt 稍微修改一下,以在窗口打开后隐藏该窗口.
You can also hack about a bit with AutoIt, to hide the window once it's opened.
这篇关于Selenium WebDriver 可以在后台静默打开浏览器窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!