forked from UmangSardesai/Codeception-BrowserStack
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBrowserStackWebDriver.php
More file actions
31 lines (24 loc) · 1.08 KB
/
BrowserStackWebDriver.php
File metadata and controls
31 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require 'vendor/autoload.php';
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class BrowserStackWebDriver extends \Codeception\Module\WebDriver
{
private $bs_local;
public function _initialize(){
getenv('BROWSERSTACK_USERNAME') ? ($this->config["capabilities"]["browserstack.user"] = getenv('BROWSERSTACK_USERNAME')) : 0;
getenv('BROWSERSTACK_ACCESS_KEY') ? ($this->config["capabilities"]["browserstack.key"] = getenv('BROWSERSTACK_ACCESS_KEY')) : 0;
if(array_key_exists("browserstack.local", $this->config["capabilities"]) && $this->config["capabilities"]["browserstack.local"])
{
$bs_local_args = array("key" => $this->config["capabilities"]["browserstack.key"]);
$this->bs_local = new BrowserStack\Local();
$this->bs_local->start($bs_local_args);
}
parent::_initialize();
}
// HOOK: after suite
public function _afterSuite() {
parent::_afterSuite();
if($this->bs_local) $this->bs_local->stop();
}
}