Header logo Open Menu Close Menu
  • Live
  • Automate
  • App Live
  • More
    • Enterprise
    • Screenshots
    • Responsive
  • Pricing
  • Resources Resources
      • Features
      • Live Features
      • Browsers & Platforms
      • Developer Tools
      • Local Testing
      • Security
      • Mobile
      • Test on Right Devices
      • Mobile Features
    • BrowserStack for Enterprise
      Learn More
  • Sign in
  • Free Trial
  • Resources
  • Features
  • Mobile
  • Features
  • Live Features
  • Browsers & Platforms
  • Developer Tools
  • Local Testing
  • Security
  • Enterprise Features
  • Mobile
  • Test on Right Devices
  • Mobile Features

Support Local Testing Local Testing

Local Testing

Local Testing allows you to test your private and internal servers, alongside public URLs, using the BrowserStack cloud, which has support for firewalls, proxies and Active Directory.

Real iOS and Android Devices are now live! Run your automated tests on physical mobile devices. View Documentation

Getting Started

Local Testing establishes a secure connection between your machine and BrowserStack servers. Once you set up Local Testing, all URLs work out of the box, including those with HTTPS, multiple domains, as well as those behind a proxy or firewall, and much more.

Live; App Live (using Chrome 31+ or Firefox 38+)

If you have already installed the features extension after signing into BrowserStack, Local Testing will be enabled. There is no additional setup required.

Users have the option of ensuring all traffic routes via their local machine exclusively by selecting the Resolve all URLs through my network checkbox. For example, if there is a public URL like "browserstack.com", but you have /etc/hosts entry for "browserstack.com" mapping to localhost or some other IP, this option will drive all 'browserstack.com' requests from remote browser/mobile device via your machine.

Note: This extension is available at the Chrome app store.

Local Testing

Warning: Enabling this option slows down the websites on the remote browser.

Live (using other browsers); Automate

Use the steps below to setup a Local Testing connection or view our use cases for more help.

  1. Download the appropriate binary:
    • OS X (10.7 and above)
    • Linux 32-bit
    • Linux 64-bit
    • Windows (XP and above)

    The download links are secure. The binaries are digitally signed, identifying the publisher as 'BrowserStack Ltd.'

  2. Navigate to the folder containing the binary, and run it from the command-line interface.
  • OS X & Linux
  • Windows

To test a private server, execute the binary:

./BrowserStackLocal --key ACCESS_KEY

A Local Testing session would have been initialized for Live and Screenshots. Automate users can now start running local tests.

Note: Learn more about using Local Testing for Selenium Tests.

Note: To extend functionality further, here is a complete list of modifiers for the binaries, or view our use cases for more help.

Use cases

Localhost

Enable Local Testing and type the address, for example localhost:3000, in the remote browser, and browse as you would on your local machine.

Private or internal server

Enable Local Testing and type the address, for example staging.example.com, in the remote browser, and browse as you would on your local machine.

HTTPS

Enable Local Testing and type the address, for example https://localhost:3000, in the remote browser, and browse as you would on your local machine.

Content served from multiple servers

Enable Local Testing and type the address, for example staging.example.com, in the remote browser. If there is content served from other URLs like assets1.staging.example.com and assets2.staging.example.com, they will work the same as on your local machine.

Subdomains

Enable Local Testing and type the address, for example dev.example.com, in the remote browser. If there are subdomains like user1.dev.example.com and user2.dev.example.com, they will work the same as on your local machine.

Configuration in hosts file

When using Local Testing, your /etc/hosts file is respected by default, and the public setting is used only when there is a conflict. To ensure that all the traffic is routed via your local machine, select the Resolve all URLs through my network checkbox when enabling Local Testing. Type the address in the remote browser and browser as you would on your local machine.

HTML design folders

Enable Local Testing, and select a folder for testing. Type the address in the remote browser and access as normal.

Using Local Testing binary

When using the command line to enable Local Testing, specify the folder with the --folder parameter to test the local folder.
Example:

./BrowserStackLocal --key ACCESS_KEY --folder /Users/test/browserstack

Note: Local folders can be tested alongside private and internal servers using the dashboard, but must be set up separately when using the command line binaries.

Warning: URLs generated for local folders can only be opened on BrowserStack remote machines. They are neither accessible from your local browser, nor from any other machine.

Behind a proxy

Enable Local Testing and type the address, for example staging.example.com, in the remote browser, and browse as you would on your local machine.

Using Local Testing Binary

When using the command line to enable Local Testing, setup the connection using the --proxy-host and --proxy-port parameters.
Example:

./BrowserStackLocal  --key ACCESS_KEY --proxy-host <proxy_host> --proxy-port <proxy_port>
BrowserMob Proxy

When using the command line to enable Local Testing, setup the connection using the --local-proxy-host and --local-proxy-port parameters.
Example:

./BrowserStackLocal --key ACCESS_KEY --local-proxy-host <browsermob_proxy_host> --local-proxy-port <browsermob_proxy_port> --local-proxy-user <proxy_username> --local-proxy-pass <proxy_password>

You can ignore --local-proxy-host and --local-proxy-pass if your proxy does not have authentication. This is valid for local binary versions v5.8 and above. To know your binary version execute ./BrowserStackLocal  --version

PAC file support

PAC file stands for Proxy Auto-Configuration file. It is a javascript function that determines whether a request should be sent via the web proxy server or not. You can use PAC files on BrowserStack using the --pac-file parameter

./BrowserStackLocal --key ACCESS_KEY --pac-file <pac_file_abs_path>
Sample PAC file

The following function checks to see whether the hostname is localhost, and if so, whether the connection is direct. If the hostname is not localhost, the connection is via proxy.

function FindProxyForURL(url, host) {
  if (isPlainHostName(host))
 	  return "DIRECT";
  else
 	  return "PROXY proxy:80";
}             

Behind a firewall or VPN

If your private or internal server is behind a firewall or only accessible through VPN, all you need to do is set up Local Testing. There is no extra configuration required; only ensure that your machine can access the private server. For more information, contact support.

Whitelist BrowserStack IPs

If you are testing a server that requires IP whitelisting, set up a Local Testing connection and select the checkbox.

Using Local Testing binary

Set up the connection using the --force-local parameter. Example:

./BrowserStackLocal --key ACCESS_KEY --force-local

You only need to ensure that your machine has access to your restricted server, since all requests are sent via that machine.

Multiple Local Testing Connections

If you are using same account to test multiple applications, you can setup named connection using the localIdentifier option

  1. Run the BrowserStackLocal binary with the localIdentifier option

    • OS X & Linux
    • Windows
    ./BrowserStackLocal --key ACCESS_KEY --local-identifier Test123
    Here, we have created a named connection called Test123.
  2. Once the connection is made, you need to set the browserstack.localIdentifier capability with the correct named connection

    desired_cap['browserstack.local'] = True
    desired_cap['browserstack.localIdentifier'] = 'Test123'
    

Determining the status of local binaries via API

Use the Local testing API to check the status of all your running local testing binaries

https://www.browserstack.com/local/v1/list?auth_token=ACCESS_KEY&last=5&state=running

Disconnect a local testing binary connection via API

Use the Local testing API to disconnect an active connection via the local binary

curl -X DELETE "https://www.browserstack.com/local/v1/QUERTY1?auth_token=ACCESS_KEY"

Modifiers for binaries

Local Testing binaries can be modified to suit individual testing cases

Argument Description
-k, --key Browserstack Access Key. This information is available in the local testing section of the Settings page: https://www.browserstack.com/accounts/settings
-f, --folder Specify the Local folder to be used for testing. This option is to be used when testing a local folder. Example: /home/ubuntu/mysite/ or C:\windows\mysite\
-h, --help Display the help text.
-V, --version Display the current version of the binary.
-F, --force Using this option kills all other instances of BrowserStack Local binary running on this machine with the same --local-identifier options. This option will not affect binaries running in remote servers and instances running with different --local-identifier options.
--only If you want to restrict BrowserStackLocal Binary access to few local servers and/or folders, use this option to restrict them. Usage: host1,port1,ssl?,host2,port2,ssl?. Example: localhost,8000,0,abc.example.com,8080,1
--force-local Route all traffic via machine where BrowserStackLocal Binary is running. Local tries to fetch public urls directly, unless this option is specified.
--verbose [1|2|3] This option sets the level of logging required. Set 1 to debug issues related to setting up connections. Set 2 for logs related to network information. Set 3 to dump all communication to local servers for each request and response. The default value for this option is 1
--only-automate This option restricts Binary usage to Automate product, and it cannot be used for Live/Screenshot testing.
--proxy-host HOST If you are behind corporate proxy setup, please specify your proxy host using this option.
--proxy-port PORT If you are behind corporate proxy setup, please specify your proxy port using this option. Default value is 3128.
--proxy-user USERNAME If you are behind corporate proxy which requires authentication, please specify your proxy username using this option. As of now, only HTTP Basic authentication is supported.
--proxy-pass PASSWORD If you are behind corporate proxy which requires authentication, please specify your proxy password using this option. As of now, only HTTP Basic authentication is supported.
--local-identifier UNIQUE STRING If you are running multiple copies of BrowserStackLocal binary (for better performance or other reasons), please specify unique strings for BrowserStack to uniquely identify them. You will need to specify the same string in Automate tests as well.
--force-proxy This options routes all traffic via the proxy specified - otherwise, binary tries to connect directly as well for better performance.
--local-proxy-host HOST If your local server is behind a proxy or you are using a proxy to log all communication to your local servers - please specify your proxy host using this option.
--local-proxy-port PORT If your local server is behind a proxy or you are using a proxy to log all communication to your local servers - please specify your proxy port using this option. Default assumed is 8081.
--local-proxy-user USERNAME If your local server is behind a proxy, and it requies authentication - please specify your proxy username using this option.
--local-proxy-pass PASSWORD If your local server is behind a proxy, and it requies authentication - please specify your proxy password using this option.
--daemon [start|stop] Starts or stop the binary as a daemon. Accepts only 2 commands: start, stop. Start will start binary in background. Primarily used in Continous Integration server scripts.
--enable-logging-for-api Include this option to make sure this binary is exposed to Local API for debugging. For more information refer to https://www.browserstack.com/local-testing#local-api-debugging
--log-file LOG FILE PATH Logs all the output to the file specified.
--pac-file PAC FILE PATH Path to pac file with which the proxy needs to be set.
--parallel-runs Specify the number of parallel runs.

Disconnection/Duration of the connection

The connection between your machine and the remote machine remains open till you explicitly disconnect it, the browser window is closed, or you sign out of your BrowserStack account. The connection is persistent, and even if you accidentally close your browser tab, you can resume testing on reopening it.

What isn't supported?

Local Testing cannot be used presently to test the following:

  • Amazon Kindle
  • NTLM

We are actively working on fixing these issues.

Local API for debugging binaries

Local API helps in listing and disconnecting instances when you are testing multiple environments in BrowserStack using binaries

Get the list of binary instances

Usage
GET /local/<version>/list 
Parameters Value
version
The version of the API to be used.
Current version is v1
last
The number of recent binary instances to be listed.
Default:20, Maximum value: 100
state
Configures to list whether all binary instances or currently running instances.
all, running
default: running
Example
https://www.browserstack.com/local/v1/list?auth_token=ACCESS_KEY&last=5&state=running

Note: On success, you will get a response code 200

Response
  {
    "api_version": "v1",
    "meta_data": { "params": {}}
    "instances": [
      {
        "lastActiveOn": "2016-07-19 14:19:43 +0000",
        "localIdentifier": "",
        "email": "[email protected]",
        "commandLineParams": "--key ACCESS_KEY --enable-logging-for-api",
        "public-IP": "8.8.4.4",
        "hostname": "my-local-box",
        "endTime": null,
        "disconnectReason": null,
        "startTime": "2016-07-19 14:12:58 +0000",
        "privateIP": ["127.0.0.1", "10.100.100.1", ….],
        "id": "QUERTY1"
      },
     {
        "lastActiveOn": "2016-07-19 14:19:43 +0000",
        "localIdentifier": "test-1",
        "email": "[email protected]",
        "commandLineParams": "--key ACCESS_KEY --enable-logging-for-api --local-identifier test-1",
        "public-IP": "8.8.4.4",
        "hostname": "my-local-box",
        "endTime": null,
        "disconnectReason": null,
        "startTime": "2016-07-19 14:12:58 +0000",
        "privateIP": ["127.0.0.1", "10.100.100.1", ….],
        "id": "QUERTY2"
      },
    ...
      ]
  }
              

Retrieve details of a binary instance using its ID

Usage
GET /local/<version>/<id> 
Parameters Value
version
The version of the API to be used.
Current version is v1
id
The Binary id that needs to be retrieved
String value
Example
https://www.browserstack.com/local/v1/QUERTY1?auth_token=ACCESS_KEY

Note: On success, you will get a response code 200

Response
  {
    "api_version": "v1",
    "meta_data": { "params": {}}
    "instances": [
      {
        "lastActiveOn": "2016-07-19 14:19:43 +0000",
        "localIdentifier": "",
        "email": "[email protected]",
        "commandLineParams": "ACCESS_KEY --enable-logging-for-api",
        "public-IP": "8.8.4.4",
        "hostname": "my-local-box",
        "endTime": null,
        "disconnectReason": null,
        "startTime": "2016-07-19 14:12:58 +0000",
        "privateIP": ["127.0.0.1", "10.100.100.1", ….],
        "id": "QUERTY1"
      }
      ]
  }
              
Error states
Response code/Description Response message
401
Authentication failed due to incorrect token.
{"error": "Invalid auth token"}
422
The ID requested for is incorrect.
{"error": "Incorrect id"}
503
There was an exception.
{"error": "Something went wrong, please try again after sometime"}

Disconnect a running binary using its ID

Usage
DELETE /local/<version>/<id> 
Parameters Value
version
The version of the API to be used.
Current version is v1
id
The Binary id that needs to be retrieved
String value
Example
 curl -X DELETE "https://www.browserstack.com/local/v1/QUERTY1?auth_token=ACCESS_KEY"

Note: On success, you will get a response code 200

Response
  {
    "api_version": "v1",
    "meta_data": { "params": {}},
    "message": "QUERTY1 successfully disconnected" / "QUERTY1 was already disconnected"
  }
              
Error states
Response code/Description Response message
401
Authentication failed due to incorrect token.
{"error": "Invalid auth token"}
422
The ID requested for is incorrect.
{"error": "Incorrect id"}
500
There was an exception.
{"error": "Failed to disconnect, please try again. Please contact [email protected] if the issue is persistent."}

Please note:
1. Requests to these APIs are throttled at 20 requests for 5 minutes
2. For these APIs to include binaries in results, the binary should have been started with 'enable-logging-for-api' parameter.
Example: ./BrowserStackLocal --key ACCESS_KEY --enable-logging-for-api <other_params>
3. In case the 'enable-logging-for-api' parameter is not used the response would have empty instance. However the instance would still be recorded in our database without storing any sensitive information.

In This Article

  • Getting Started
    • Live (using Chrome 31+ or Firefox 38+)
    • App Live (Using Chrome 31+ or Firefox 38+)
    • Live (using other browsers)
    • Automate
  • Use cases
    • Localhost
    • Private or internal server
    • HTTPS
    • Content served from multiple servers
    • Subdomains
    • Configuration in hosts file
    • HTML design folders
    • Behind a proxy
    • Behind a firewall or VPN
    • Whitelist BrowserStack IPs
    • Multiple Local Testing Connections
    • Determining the status of local binaries via API
    • Disconnect a local testing binary connection via API
  • Modifiers for binaries
  • What isn't supported?
  • Disconnection/Duration of the connection
  • Local API for debugging binaries
    • Get the list of binary instances
    • Retrieve a binary instance using its ID
    • Disconnect a running binary using its ID

Related Articles

Local Testing Internals

Products
  • Live
  • Automate
  • App Live New
  • Screenshots
  • Responsive
  • Enterprise New
Mobile
  • Test on Right Devices
  • Mobile Features
  • Mobile Emulators
Other Links
  • Test in IE
  • Careers We're hiring!
  • Support
  • Contact
Social
Header logo

© 2011-2017 BrowserStack - A cross-browser testing tool.

  • Terms of Service
  • Privacy Policy