Selenium and firefox in php

Below example illustrates how to launch the Firefox browser using Selenium in PHP. Note that you will have to add the Geckodriver in system PATH to be able to automate latest Firefox with Selenium 3.0 and above.
 

<?php
class LaunchFirefox extends PHPUnit_Framework_TestCase {

protected $webDriver;

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

protected $url = ‘https://www.softpost.org’;

public function testTitle()
{
$this->webDriver->get($this->url);

// checking that page title contains word ‘Tutorial’
$this->assertContains(‘Tutorial’, $this->webDriver->getTitle());
}

public function tearDown()
{
//Close the browser
$this->webDriver->quit();
}
}
?>

Complex problems, Simple Solutions