Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created October 27, 2020 13:34
Show Gist options
  • Save muditlambda/1f5e7460da69fdc56d93b4df9f89dbf8 to your computer and use it in GitHub Desktop.
Save muditlambda/1f5e7460da69fdc56d93b4df9f89dbf8 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use PHPUnit\Framework\TestCase;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;
$GLOBALS['LT_USERNAME'] = "user-name";
# accessKey: AccessKey can be generated from automation dashboard or profile section
$GLOBALS['LT_APPKEY'] = "access-key";
class LTWebsiteTest extends TestCase
{
protected $webDriver;
public function build_browser_capabilities(){
/* $capabilities = DesiredCapabilities::chrome(); */
$capabilities = array(
"build" => "[PHP] Test-3 on IE and Windows 10",
"name" => "[PHP] Test-3 on IE and Windows 10",
"platform" => "Windows 10",
"browserName" => "Internet Explorer",
"version" => "11.0",
"ie.compatibility" => 11001
);
return $capabilities;
}
public function setUp(): void
{
$capabilities = $this->build_browser_capabilities();
/* Download the Selenium Server 3.141.59 from
https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
*/
$url = "https://". $GLOBALS['LT_USERNAME'] .":" . $GLOBALS['LT_APPKEY'] ."@hub.lambdatest.com/wd/hub";
$this->webDriver = RemoteWebDriver::create($url, $capabilities);
}
public function tearDown(): void
{
$this->webDriver->quit();
}
/*
* @test
*/
public function test_LT_Blog()
{
$expected_title = "Most Powerful Cross Browser Testing Tool Online | LambdaTest";
$this->webDriver->get("https://www.google.com/ncr");
$this->webDriver->manage()->window()->maximize();
sleep(5);
$element = $this->webDriver->findElement(WebDriverBy::name("q"));
if($element) {
$element->sendKeys("LambdaTest");
$element->submit();
}
/* Click on the first result */
$search_result = $this->webDriver->findElement(WebDriverBy::Xpath("//h3[.='LambdaTest: Most Powerful Cross Browser Testing Tool Online']"));
$search_result->click();
sleep(5);
print $this->webDriver->getTitle();
$this->assertEquals($expected_title, $this->webDriver->getTitle());
print "Test Completed";
}
}
?>
@peter279k
Copy link

According to the official PHPUnit doc, it should be protected function setUp(): void and protected function tearDown(): void methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment