Skip to content
Snippets Groups Projects
Commit f95d0d9f authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

create custom trait for browserstack to support non local setup

parent d9bc7b1e
No related branches found
No related tags found
5 merge requests!1645Development,!1635Development,!1634Development,!1631Development,!1628Resolve "Add more integration tests"
<?php
namespace App\Traits;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
/**
* Run BrowserStack from your tests.
*/
trait SupportsBrowserStack
{
protected static $web_driver, $bs_local;
/**
* Create the BrowserStack WebDriver instance.
*/
public function createBrowserStackDriver(array $config = null): RemoteWebDriver
{
if ($config["capabilities"]["browserstack.local"] === "true") {
$this->bs_local = new Local();
$bs_local_args = [
"key" => $config["key"],
];
$this->bs_local->start($bs_local_args);
}
$this->web_driver = RemoteWebDriver::create(
"https://$config[username]:$config[key]@hub-cloud.browserstack.com/wd/hub",
$config["capabilities"]
);
return $this->web_driver;
}
/**
* @afterClass
*/
public static function shutdown()
{
if (static::$bs_local && static::$bs_local->isRunning()) {
static::$bs_local->stop();
}
if (static::$web_driver) {
static::$web_driver->quit();
}
}
}
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
"browserstack/browserstack-local": "^1.1", "browserstack/browserstack-local": "^1.1",
"filp/whoops": "^2.0", "filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4", "fzaninotto/faker": "^1.4",
"galahad/dusk-browserstack": "^2.0",
"laravel/dusk": "^5.0", "laravel/dusk": "^5.0",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0", "nunomaduro/collision": "^3.0",
...@@ -71,4 +70,4 @@ ...@@ -71,4 +70,4 @@
"@php artisan key:generate --ansi" "@php artisan key:generate --ansi"
] ]
} }
} }
\ No newline at end of file
/bin/sh: 1: ps: not found
/bin/sh: 1: ps: not found
Tue Aug 04 2020 12:39:58 GMT+0000 (UTC) -- [INFO] Started the BrowserStack Binary server on 45691, PID: 28
Tue Aug 04 2020 12:39:58 GMT+0000 (UTC) -- [SUCCESS] You can now access your local server(s) in our remote browser
Tue Aug 04 2020 12:39:59 GMT+0000 (UTC) -- Press Ctrl-C to exit
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
namespace Tests; namespace Tests;
use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\RemoteWebDriver;
use Galahad\BrowserStack\SupportsBrowserStack;
use Laravel\Dusk\TestCase as BaseTestCase; use Laravel\Dusk\TestCase as BaseTestCase;
use \App\Traits\SupportsBrowserStack;
abstract class DuskTestCase extends BaseTestCase abstract class DuskTestCase extends BaseTestCase
{ {
...@@ -51,9 +51,6 @@ abstract class DuskTestCase extends BaseTestCase ...@@ -51,9 +51,6 @@ abstract class DuskTestCase extends BaseTestCase
"username" => env("WEBDRIVER_USER", ""), "username" => env("WEBDRIVER_USER", ""),
"key" => env("WEBDRIVER_KEY", ""), "key" => env("WEBDRIVER_KEY", ""),
"capabilities" => $capabilities, "capabilities" => $capabilities,
"local_config" => [
"key" => env("WEBDRIVER_KEY", ""),
],
]); ]);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment