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 Element Identification in php
We can identify the web elements using below Element locators in Node.js- className
- tagName
- name
- id
- xpath
- css
- linkText
- partialLinkText
- WebDriverBy::className()
- WebDriverBy::tagName()
- WebDriverBy::name()
- WebDriverBy::id()
- WebDriverBy::xpath()
- WebDriverBy::cssSelector()
- WebDriverBy::linkText()
- WebDriverBy::partialLinkText()
<?php
class LinkTest 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);
}
public function tearDown()
{
$this->webDriver->quit();
}
public function testLink()
{
$this->webDriver->get(“https://www.softpost.org”);
//Show all links containing selenium on page
$links = $this->webDriver->findElements(WebDriverBy::partialLinkText(‘Selenium’));
foreach($links as $link)
{
echo (“
” . $link->getAttribute(‘href’) . “
”);
}
//find and click Selenium link
$seleniumLink = $this->webDriver->findElement(WebDriverBy::linkText(‘Selenium’));
$seleniumLink->click();
$this->webDriver->close();
}
}
?>
Web development and Automation testing
solutions delivered!!