selenium-webdriverselenium-firefoxdriverselenium-java

What is the updated argument for Firefox browser to run test (Selenium Java) in headless mode?


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.


Solution

  • 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);