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 assertions in php
We can use Assertion library provided in PHPUnit as shown in below example.
<?php
class AssertionTest 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/selenium-test-page”);
$this->assertContains(‘Tutorial’, $this->webDriver->getTitle());
$this->assertTrue(‘Selenium Test Page | Free Software Tutorials’==$this->webDriver->getTitle());
$this->assertFalse(‘Selenium Test Page | Free Software Tutorials’!=$this->webDriver->getTitle());
$this->assertEquals(‘Selenium Test Page | Free Software Tutorials’, $this->webDriver->getTitle());
$this->assertSame(‘Selenium Test Page | Free Software Tutorials’, $this->webDriver->getTitle());
$this->assertGreaterThan(2,4,”Verifying that 4 is greater than 2″);
$this->assertGreaterThanOrEqual(2,4,””);
$this->assertLessThan(14,12,””);
$this->assertLessThanOrEqual(14,12,””);
$this->webDriver->close();
}
}
?>
Web development and Automation testing
solutions delivered!!