Php-webdriver: Start Firefox in headless mode

Created on 23 Nov 2017  路  4Comments  路  Source: php-webdriver/php-webdriver

What are you trying to achieve? (Expected behavior)

As with Chrome, I want to be able to start Firefox in headless mode.

What do you get instead? (Actual behavior)

Can't find any method similar to the ChromeOptions->addArguments(); Can I use setPreference()?

How could the issue be reproduced? (Steps to reproduce)

// You can insert your PHP code here (or remove this block if it is not relevant for the issue).

Details

  • Php-webdriver version:
  • PHP version:
  • Selenium server version:
  • Operating system:
  • Browser used + version:
waiting for reaction

Most helpful comment

Hi, I believe you can pass the settings via desired capabilities:

$capabilities = DesiredCapabilities::firefox();

$capabilities->setCapability(
    'moz:firefoxOptions',
   ['args' => ['-headless']]
);

$driver = RemoteWebDriver::create($host, $capabilities);

@olleharstedt Could you please try this solution as well? I will add it to the wiki then.

All 4 comments

Possible solution: Use export MOZ_HEADLESS=1 before running selenium.

Hi, I believe you can pass the settings via desired capabilities:

$capabilities = DesiredCapabilities::firefox();

$capabilities->setCapability(
    'moz:firefoxOptions',
   ['args' => ['-headless']]
);

$driver = RemoteWebDriver::create($host, $capabilities);

@olleharstedt Could you please try this solution as well? I will add it to the wiki then.

Thanks, I'll try this.

I can confirm this works.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings