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 advanced operations in php
Below example shows how to perform complex actions using Selenium in PHP like drag and drop, moving to element, double clicking on an element, right clicking on an element etc.
<?php
class MyTest extends PHPUnit_Framework_TestCase {
protected $webDriver;
public function setUp()
{
$capabilities = array(WebDriverCapabilityType::BROWSER_NAME => ‘chrome’);
$this->webDriver = RemoteWebDriver::create(‘https://localhost:4444/wd/hub’, $capabilities);
$this->webDriver->manage()->window()->maximize();
}
public function testActions()
{
$this->webDriver->get(“https://www.softpost.org/selenium-test-page”);
$e1 = $this->webDriver->findElement(WebDriverBy::id(‘fn’));
$e2 = $this->webDriver->findElement(WebDriverBy::linkText(‘Selenium in Java’));
$action = new WebDriverActions($this->webDriver);
$action->moveToElement($e1)->click($e2)->perform();
sleep(3);
//Similarly you can perform below actions.
//clickAndHold(), contextClick(), doubleClick()
//dragAndDrop(), dragAndDropBy(), moveByOffset(), moveToElement()
//keyDown(), keyUp(), release(), sendKeys()
}
public function tearDown()
{
//Quit the driver
$this->webDriver->quit();
}
}
?>
Web development and Automation testing
solutions delivered!!