Selenium and chrome options in php

Below example shows how to launch the chrome browser with various options (arguments) in Selenium in PHP.
 
<?php
class LaunchChrome extends PHPUnit_Framework_TestCase {

protected $driver;

public function setUp()
{
$options = new ChromeOptions();

// Use different chrome binary
//$options->setBinary(‘/path_to_binary’);

//Setting Arguments for the chrome browser
$options->addArguments(array(
‘–disable-extensions’,
‘start-maximized’,
‘disable-popup-blocking’,
‘test-type’
));

//Add extensions for chrome browser
$options->addExtensions(array(
//give path to .crx extension file’,
));

$caps = DesiredCapabilities::chrome();
$caps->setCapability(ChromeOptions::CAPABILITY, $options);
$this->driver = RemoteWebDriver::create(‘https://localhost:4444/wd/hub’, $caps);
}

public function testChromeOptions()
{
$this->driver->get(“https://www.softpost.org”);
// checking that page title contains word ‘Tutorial’
$this->assertContains(‘Tutorial’, $this->driver->getTitle());
}

public function tearDown()
{
//Quit the driver
$this->driver->quit();
}
}
?>

Complex problems, Simple Solutions