Skip to content

Commit 6df1690

Browse files
committed
initial commit
0 parents  commit 6df1690

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

Lambdatest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
/*
4+
LambdaTest selenium automation sample example
5+
Configuration
6+
----------
7+
username: Username can be found at automation dashboard
8+
accessToken: AccessToken can be generated from automation dashboard or profile section
9+
10+
Result
11+
-------
12+
Execute PHP Automation Tests on LambdaTest Distributed Selenium Grid
13+
*/
14+
15+
require 'vendor/autoload.php';
16+
17+
class LambdaTest{
18+
19+
/*
20+
Setup remote driver
21+
Params
22+
----------
23+
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)
24+
browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge, Safari)
25+
version : Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
26+
*/
27+
protected static $driver;
28+
29+
public function searchTextOnGoogle() {
30+
# username: Username can be found at automation dashboard
31+
$LT_USERNAME = "{username}";
32+
33+
# accessKey: AccessKey can be generated from automation dashboard or profile section
34+
$LT_APPKEY = "{accessKey}";
35+
36+
$LT_BROWSER = "chrome";
37+
$LT_BROWSER_VERSION ="63.0";
38+
$LT_PLATFORM = "windows 10";
39+
40+
# URL: https://{username}:{accessToken}@beta-hub.lambdatest.com/wd/hub
41+
$url = "https://". $LT_USERNAME .":" . $LT_APPKEY ."@beta-hub.lambdatest.com/wd/hub";
42+
43+
# setting desired capabilities for the test
44+
$desired_capabilities = new DesiredCapabilities();
45+
$desired_capabilities->setCapability('browserName',$LT_BROWSER);
46+
$desired_capabilities->setCapability('version', $LT_BROWSER_VERSION);
47+
$desired_capabilities->setCapability('platform', $LT_PLATFORM);
48+
$desired_capabilities->setCapability('name', "Php");
49+
$desired_capabilities->setCapability('build', "Php Build");
50+
$desired_capabilities->setCapability('network', true);
51+
$desired_capabilities->setCapability('visual', true);
52+
$desired_capabilities->setCapability('video ', true);
53+
$desired_capabilities->setCapability('console', true);
54+
55+
/*
56+
Setup remote driver
57+
Params
58+
----------
59+
Execute test: navigate google.com search LambdaTest
60+
Result
61+
-------
62+
print title
63+
*/
64+
self::$driver = RemoteWebDriver::create($url, $desired_capabilities);
65+
66+
self::$driver->get("https://www.google.com/ncr");
67+
68+
$element = self::$driver->findElement(WebDriverBy::name("q"));
69+
if($element) {
70+
$element->sendKeys("LambdaTest");
71+
$element->submit();
72+
}
73+
74+
print self::$driver->getTitle();
75+
self::$driver->quit();
76+
}
77+
}
78+
79+
$lambdaTest = new LambdaTest();
80+
$lambdaTest->searchTextOnGoogle();
81+
82+
?>
83+

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## PHP Automation Lambdatest
2+
3+
PHP selenium automation sample test for Lambdatest Cloud GRID.
4+
5+
## Install PHP
6+
- Download & Install PHP from
7+
http://php.net/manual/en/install.php
8+
9+
## Install Composer
10+
```bash
11+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
12+
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
13+
php composer-setup.php
14+
php -r "unlink('composer-setup.php');"
15+
16+
```
17+
18+
## Composer configuration
19+
- Create composer.json file with following dependencies
20+
```bash
21+
{
22+
"require": {
23+
"phpunit/phpunit-selenium": "*",
24+
"facebook/webdriver": "dev-master"
25+
}
26+
}
27+
```
28+
- Install dependencies
29+
```bash
30+
composer install
31+
```
32+
33+
34+
### Configuring test.
35+
- Replace {username} with your username
36+
- Replace {accessToken} with your username
37+
- List of supported platfrom, browser, version can be found at https://www.lambdatest.com/capabilities-generator/
38+
39+
40+
### Executing test
41+
```bash
42+
vendor/bin/phpunit Lambdatest.php
43+
```

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"require": {
3+
"phpunit/phpunit-selenium": "*",
4+
"facebook/webdriver": "dev-master"
5+
}
6+
}

0 commit comments

Comments
 (0)