简体   繁体   中英

How to use BrowserStack with Symfony Panther

In the Symfony Panther docs it states:

Even if Chrome is the default choice, Panther can control any browser supporting the WebDriver protocol. It also supports remote browser testing services such as Selenium Grid (open source), SauceLabs and Browserstack.

But, there are no other documentation on how to do this.

How do you implement BrowserStack as a remote browser for Panther?

This is how to create a new Panther client using a BrowserStack remote browser:

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Symfony\Component\Panther\Client;

$capabilities = array(
    "os"                       => "OS X",
    "os_version"               => "Monterey",
    "browser"                  => "Chrome",
    "browser_version"          => "latest",
    "name"                     => "Test",
    "build"                    => "Build 1.0",
    "browserstack.debug"       => true,
    "browserstack.console"     => "info",
    "browserstack.networkLogs" => true,
    "disableCorsRestrictions"  => true,
    "wsLocalSupport"           => true,
    "geoLocation"              => "US"
);
$caps = DesiredCapabilities::chrome();
foreach ($capabilities as $key => $value) {
    $caps->setCapability($key, $value);
}
$client = Client::createSeleniumClient('https://[YOUR_BROWSERSTACK_USERNAME]:[YOUR_BROWSERSTACK_ACCESS_KEY]@hub-cloud.browserstack.com/wd/hub', $caps);

$client->request('GET', 'https://stackoverflow.com/');

You can see a list of capabilities here: https://www.browserstack.com/automate/capabilities

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM