Selenium + PHP
Introduction to Selenium Webdriver Installation and Environment set up Chrome Chrome with options Chrome in Mobile Emulation IE Firefox Element identification methods Assertions in Selenium in PHP Interacting with elements in Selenium in PHP Basic Browser window automation Sending keys in Selenium in PHP Synchronization in Selenium Check if Element exists Working with Tables using Selenium Performing advanced actions using Selenium in PHP Executing JavaScript in Selenium in PHP Working with multiple Browser Windows or tabs Working with multiple frames Handling alerts Taking a screenshot in selenium Integration with BDD framework like behatSelenium 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.
<?php
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()
{
$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();
}
}
//To execute this test, you need to use below command.
//vendor/bin/phpunit LaunchChrome.php
?>
Web development and Automation testing
solutions delivered!!