|
5 | 5 | use Facebook\WebDriver\WebDriverExpectedCondition; |
6 | 6 | use BrowserStack\Local; |
7 | 7 |
|
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(); |
18 | 8 | $caps = array( |
19 | 9 | 'bstack:options' => array( |
20 | 10 | "os" => "OS X", |
|
27 | 17 | "browserName" => "Chrome", |
28 | 18 | "browserVersion" => "latest", |
29 | 19 | ); |
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); |
31 | 35 | try{ |
32 | 36 | $web_driver->get("http://bs-local.com:45691/check"); |
33 | 37 | $body_text = $web_driver->wait(10000)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector("body")))->getText(); |
|
0 commit comments