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 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();
}
}
?>
Web development and Automation testing
solutions delivered!!