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 behatCheck if element exists Selenium in php
Below example shows how to check if specific element exists on the web page or not.
<?php
class TestSize 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 testSize()
{
$this->webDriver->get(“https://www.softpost.org/selenium-test-page”);
$elements = $this->webDriver->findElements(WebDriverBy::id(‘fn’));
if (sizeof($elements)==0)
echo(“
Element with id fn not found”);
else
echo(“
Element with id fn found”);
}
public function tearDown()
{
//Quit the driver
$this->webDriver->quit();
}
}
?>
Web development and Automation testing
solutions delivered!!