Selenium and chrome in php

Below example illustrates how to launch the chrome browser using Selenium in PHP. You may get error saying “WebDriverCurlException – Curl error thrown for http POST to /session with params”. To avoid this error, make sure that you have installed latest driver exe files.

class LaunchChrome extends PHPUnit_Framework_TestCase {

protected $driver;

public function setUp()
$capabilities = array(WebDriverCapabilityType::BROWSER_NAME => ‘chrome’);
$this->driver = RemoteWebDriver::create(‘https://localhost:4444/wd/hub’, $capabilities);

public function testLaunchChrome()
// checking that page title contains word ‘Tutorial’
$this->assertContains(‘Tutorial’, $this->driver->getTitle());

public function tearDown()
//Quit the driver

//To execute this test, you need to use below command.
//vendor/bin/phpunit LaunchChrome.php

Web development and Automation testing

solutions delivered!!