英文:
What is the updated argument for Firefox browser to run test (Selenium Java) in headless mode?
问题
我已经尝试将参数设置为 options.addArguments("--headless");
,但它不起作用。请注意,我不想使用 setHeadless(Boolean)
方法,因为它现在已被弃用。
我已经通过以下代码在无头模式下使用 Chrome 成功:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new");
driver = WebDriverManager.chromedriver().capabilities(options).create();
我想在 Firefox 中做同样的事情。当我使用 options.addArguments("--headless");
时,它无法与页面元素交互。我确保没有其他元素遮挡了可交互的元素。
英文:
I have tried to set the argument as options.addArguments("--headless");
but it's not working. Please note that I don't want to use setHeadless(Boolean)
method since it's deprecated now.
I have a working Chrome in headless with the following code:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new");
driver = WebDriverManager.chromedriver().capabilities(options).create();
And I want to do the same with Firefox. When I use options.addArguments("--headless");
it can not interact with the page element. I'm assuring that there are no other element to obscure the interactable element.
答案1
得分: 0
在Firefox选项文档中提到,可以使用"-headless"或"--headless"
addArguments("-headless")
完成
FirefoxOptions options = new FirefoxOptions();
options.addArguments("-headless");
WebDriver driver = new FirefoxDriver(options);
英文:
Its mentioned in Firefox options docs use "-headless" or "--headless" also works
addArguments("-headless")
complete
FirefoxOptions options = new FirefoxOptions();
options.addArguments("-headless");
WebDriver driver = new FirefoxDriver(options);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论