Home > OS >  How to use BrowserStack with Symfony Panther
How to use BrowserStack with Symfony Panther

Time:11-24

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?

CodePudding user response:

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

CodePudding user response:

You can also refer to this -

https://github.com/symfony/panther/blob/main/examples/basic.php

https://stefanoalletti.wordpress.com/2018/07/02/symfony-docker-behat-browserstack-testing-your-app-like-a-boss/

https://symfony.com/blog/introducing-symfony-panther-a-browser-testing-and-web-scrapping-library-for-php

If you face any issue, please create a support ticket with them.

  • Related