Skip to content

Commit 65d11eb

Browse files
committed
variable credentails
1 parent 71930ed commit 65d11eb

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ $caps = array(
3939
"browserName" => "Chrome",
4040
"browserVersion" => "latest",
4141
);
42-
// IMP: Use your browserstack username and accesskey
43-
$web_driver = RemoteWebDriver::create("https://USERNAME:[email protected]/wd/hub", $caps);
42+
43+
// Set you credentails
44+
$BROWSERSTACK_USERNAME = "BROWSERSTACK_USERNAME";
45+
$BROWSERSTACK_ACCESS_KEY = "BROWSERSTACK_ACCESS_KEY";
4446
```
4547

4648
## To run tests

scripts/local.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
use Facebook\WebDriver\WebDriverExpectedCondition;
66
use BrowserStack\Local;
77

8-
# Creates an instance of Local
9-
$bs_local = new Local();
10-
11-
# You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
12-
$bs_local_args = array("key" => "ACCESS_KEY");
13-
# Starts the Local instance with the required arguments
14-
$bs_local->start($bs_local_args);
15-
16-
# Check if BrowserStack local instance is running
17-
echo $bs_local->isRunning();
188
$caps = array(
199
'bstack:options' => array(
2010
"os" => "OS X",
@@ -27,7 +17,21 @@
2717
"browserName" => "Chrome",
2818
"browserVersion" => "latest",
2919
);
30-
$web_driver = RemoteWebDriver::create("https://USERNAME:[email protected]/wd/hub",$caps);
20+
$BROWSERSTACK_USERNAME = "BROWSERSTACK_USERNAME";
21+
$BROWSERSTACK_ACCESS_KEY = "BROWSERSTACK_ACCESS_KEY";
22+
23+
# Creates an instance of Local
24+
$bs_local = new Local();
25+
26+
# You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
27+
$bs_local_args = array("key" => $BROWSERSTACK_ACCESS_KEY);
28+
# Starts the Local instance with the required arguments
29+
$bs_local->start($bs_local_args);
30+
31+
# Check if BrowserStack local instance is running
32+
echo $bs_local->isRunning();
33+
34+
$web_driver = RemoteWebDriver::create("https://$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",$caps);
3135
try{
3236
$web_driver->get("http://bs-local.com:45691/check");
3337
$body_text = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector("body")))->getText();

scripts/single.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
"browserName" => "Chrome",
1616
"browserVersion" => "latest",
1717
);
18-
$web_driver = RemoteWebDriver::create("https://USERNAME:[email protected]/wd/hub",$caps);
18+
19+
$BROWSERSTACK_USERNAME = "BROWSERSTACK_USERNAME";
20+
$BROWSERSTACK_ACCESS_KEY = "BROWSERSTACK_ACCESS_KEY";
21+
22+
$web_driver = RemoteWebDriver::create("https://$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",$caps);
1923
try{
2024
$web_driver->get("https://bstackdemo.com/");
2125
$web_driver->wait(10000)->until(WebDriverExpectedCondition::titleIs("StackDemo"));

0 commit comments

Comments
 (0)