ChromeOptions

Yohan edited this page Nov 30, 2017 · 9 revisions

ChromeOptions is the class managing the chrome capabilities in ChromeDriver. You can find more details in https://sites.google.com/a/chromium.org/chromedriver/capabilities. Here is the guide of using ChromeOptions in facebook/php-webdriver.

Create an instance of ChromeOptions

    $options = new ChromeOptions();

Using a different Chrome executable

    // Setting the binary is optional. 
    $options->setBinary('/home/php-webdriver/chrome/my_chrome_binary');

Adding Arguments

    // Available options:
    // http://peter.sh/experiments/chromium-command-line-switches/
    $options->addArguments(array(
      '--window-size=571,428',
    ));

Launch with Chrome extensions

    // Setting extensions is also optional
    $options->addExtensions(array(
      '/path/to/chrome/extension1.crx',
      '/path/to/chrome/extension2.crx',
    ));

Starting Chrome with the above configuration

    $caps = DesiredCapabilities::chrome();
    $caps->setCapability(ChromeOptions::CAPABILITY, $options);

    $driver = RemoteWebDriver::create($url, $caps);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.