Skip to main content
Introducing the Automate SDK! Get your entire test suite running on BrowserStack in minutes! Learn More.

Test on Internal Networks

BrowserStack enables you to run your Behat automated tests on your internal development environments, on localhost, and from behind a corporate firewall. This feature is called “Local Testing”.

Local Testing establishes a secure connection between your machine and the BrowserStack cloud. Once you set up Local Testing, all URLs work out of the box, including HTTPS URLs and those behind a proxy or firewall.

Configuring your Behat tests for Local Testing takes just three steps:

Step 1: Download and install the BrowserStackLocal binary:

# Install using composer
php composer.phar install browserstack/browserstack-local

Step 2: Next, you need to update your Behat config file, and set the browserstack.local capability to true:

default:
    paths:
        features: '../features/local'
        bootstrap:  '../features/bootstrap'
    context:
        parameters:
            browserstack:
                server: "hub-cloud.browserstack.com"
                user: "YOUR_USERNAME"
                key: "YOUR_ACCESS_KEY"

                capabilities:
                    "browserstack.local": true

                environments:
                    -
                        browser: "chrome"

Here is a sample test case written for running local with Behat.

// Local Feature
Feature: BrowserStack Local Testing

Scenario: Can check tunnel working
    Given I am on "http://bs-local.com:45691/check"
    Then I should see "Up and running"
// Feature Context
class FeatureContext extends BrowserStackContext {
  /** @Given /^I am on "([^"]*)"$/ */
  public function iAmOnSite($url) {
    self::$driver->get($url);
  }

  /** @Then /^I should see "([^"]*)"$/ */
  public function iShouldSee($string) {
    $source = self::$driver->getPageSource();
    if (strpos($source, $string) === false) {
      throw new Exception("Expected to see: '". $string. "'' Actual is: '". $source. "'");
    }
  }
}

Step 3: You can now run your Behat test using BrowserStack Local with the following command:

# Run using composer
composer local

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert