Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created November 20, 2020 14:18
<?php
require 'vendor/autoload.php';
class LambdaTestGrid{
/*
Setting up remote driver in LambdaTestGrid
Params
----------
platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7, macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge, Safari)
version : Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
*/
protected static $driver;
public function searchTextOnGoogle() {
# username: replace your username that can be found in your LambdaTest dashboard
$LT_USERNAME = "{username}";
# accessKey: replace your access token that has been generated once you signed up
$LT_APPKEY = "{accessKey}";
$LT_BROWSER = "chrome";
$LT_BROWSER_VERSION ="70.0";
$LT_PLATFORM = "windows 10";
# URL: https://{username}:{accessToken}@hub.lambdatest.com/wd/hub
$url = "https://". $LT_USERNAME .":" . $LT_APPKEY ."@hub.lambdatest.com/wd/hub";
# setting desired capabilities for the test
$desired_capabilities = new DesiredCapabilities();
$desired_capabilities->setCapability('browserName',$LT_BROWSER);
$desired_capabilities->setCapability('version', $LT_BROWSER_VERSION);
$desired_capabilities->setCapability('platform', $LT_PLATFORM);
$desired_capabilities->setCapability('name', "Php");
$desired_capabilities->setCapability('build', "Php Build");
$desired_capabilities->setCapability('network', true);
$desired_capabilities->setCapability('visual', true);
$desired_capabilities->setCapability('video ', true);
$desired_capabilities->setCapability('console', true);
self::$driver = RemoteWebDriver::create($url, $desired_capabilities);
//specify the browser URL
self::$driver->get("https://www.google.com/");
//specify the locator of the search box
$element = self::$driver->findElement(WebDriverBy::name("q"));
if($element) {
//type the name to be searched in the google search box
$element->sendKeys("IPhone");
$element->submit();
}
print self::$driver->getTitle();
self::$driver->quit();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment