Skip to content

Commit 9977a4d

Browse files
committed
fix single.php indentation
1 parent 45c504d commit 9977a4d

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

scripts/single.php

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
<?php
2-
require_once('vendor/autoload.php');
3-
use Facebook\WebDriver\Remote\RemoteWebDriver;
4-
use Facebook\WebDriver\WebDriverBy;
5-
use Facebook\WebDriver\WebDriverExpectedCondition;
6-
$caps = array(
7-
'bstack:options' => array(
8-
"os" => "OS X",
9-
"osVersion" => "Sierra",
10-
"buildName" => "BStack Build Number 1",
11-
"sessionName" => "BStack-[Php] Sample Test",
12-
"local" => "false",
13-
"seleniumVersion" => "4.0.0",
14-
),
15-
"browserName" => "Chrome",
16-
"browserVersion" => "latest",
17-
);
2+
require_once('vendor/autoload.php');
3+
use Facebook\WebDriver\Remote\RemoteWebDriver;
4+
use Facebook\WebDriver\WebDriverBy;
5+
use Facebook\WebDriver\WebDriverExpectedCondition;
6+
7+
$caps = array(
8+
'bstack:options' => array(
9+
"os" => "OS X",
10+
"osVersion" => "Sierra",
11+
"buildName" => "BStack Build Number 1",
12+
"sessionName" => "BStack-[Php] Sample Test",
13+
"local" => "false",
14+
"seleniumVersion" => "4.0.0",
15+
),
16+
"browserName" => "Chrome",
17+
"browserVersion" => "latest",
18+
);
1819

19-
$BROWSERSTACK_USERNAME = "BROWSERSTACK_USERNAME";
20-
$BROWSERSTACK_ACCESS_KEY = "BROWSERSTACK_ACCESS_KEY";
20+
$BROWSERSTACK_USERNAME = "BROWSERSTACK_USERNAME";
21+
$BROWSERSTACK_ACCESS_KEY = "BROWSERSTACK_ACCESS_KEY";
2122

22-
$web_driver = RemoteWebDriver::create("https://$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",$caps);
23-
try{
24-
$web_driver->get("https://bstackdemo.com/");
25-
$web_driver->wait(10000)->until(WebDriverExpectedCondition::titleIs("StackDemo"));
26-
# getting text of the product
27-
$product_on_page = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='1']/p")))->getText();
28-
# clicking the 'Add to cart' button
29-
$web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='1']/div[4]")))->click();
30-
# checking whether the cart pane is present on webpage
31-
$web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::className("float-cart__content")));
32-
# getting text of the product
33-
$product_in_cart = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='__next']/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")))->getText();
34-
# Setting the status of test as 'passed' or 'failed' based on the condition; if title of the web page starts with 'BrowserStack'
35-
if ($product_on_page == $product_in_cart){
36-
$web_driver->executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed", "reason": "Product has been successfully added to the cart!"}}' );
37-
} else {
38-
$web_driver->executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed", "reason": "Failed to add product to the cart or some elements might have failed to load."}}');
23+
$web_driver = RemoteWebDriver::create("https://$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",$caps);
24+
try{
25+
$web_driver->get("https://bstackdemo.com/");
26+
$web_driver->wait(10000)->until(WebDriverExpectedCondition::titleIs("StackDemo"));
27+
# getting text of the product
28+
$product_on_page = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='1']/p")))->getText();
29+
# clicking the 'Add to cart' button
30+
$web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='1']/div[4]")))->click();
31+
# checking whether the cart pane is present on webpage
32+
$web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::className("float-cart__content")));
33+
# getting text of the product
34+
$product_in_cart = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::XPath("//*[@id='__next']/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")))->getText();
35+
# Setting the status of test as 'passed' or 'failed' based on the condition; if title of the web page starts with 'BrowserStack'
36+
if ($product_on_page == $product_in_cart){
37+
$web_driver->executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed", "reason": "Product has been successfully added to the cart!"}}' );
38+
} else {
39+
$web_driver->executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed", "reason": "Failed to add product to the cart or some elements might have failed to load."}}');
40+
}
3941
}
40-
}
41-
catch(Exception $e){
42-
echo 'Message: ' .$e->getMessage();
43-
}
44-
$web_driver->quit();
42+
catch(Exception $e){
43+
echo 'Message: ' .$e->getMessage();
44+
}
45+
$web_driver->quit();
4546
?>

0 commit comments

Comments
 (0)