Registry / testing / browserstack-local

browserstack-local

JSON →
library1.2.14pypypi✓ verified 35d ago

The `browserstack-local` Python library provides bindings for the BrowserStack Local testing feature. It allows users to test websites hosted on local development environments, staging environments, or behind firewalls/proxies, by establishing a secure tunnel between the user's machine and the BrowserStack cloud. The library is currently at version 1.2.14 and maintains an active development status with a positive release cadence, often releasing new versions within three months.

testinghttp-networkingdevops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from browserstack.local import Local

This example demonstrates how to initialize, start, check the status of, and stop a BrowserStack Local tunnel. It uses an environment variable for the BrowserStack Access Key, which is the recommended practice for security. The `verbose` option is added for detailed logging.

import os from browserstack.local import Local bs_local = Local() # Replace <browserstack-accesskey> with your key or set as environment variable BROWSERSTACK_ACCESS_KEY access_key = os.environ.get('BROWSERSTACK_ACCESS_KEY', 'YOUR_BROWSERSTACK_ACCESS_KEY') bs_local_args = { "key": access_key, "verbose": "true" # Optional: enable verbose logging } try: # Start the Local instance bs_local.start(**bs_local_args) print("BrowserStack Local started.") # Check if BrowserStack Local instance is running if bs_local.isRunning(): print("BrowserStack Local is running.") # Your test logic here that uses the local tunnel else: print("BrowserStack Local is NOT running.") finally: # Stop the Local instance if bs_local.isRunning(): bs_local.stop() print("BrowserStack Local stopped.")
Debug
Known footguns
gotchaBinary download issues or corruption: The `browserstack-local` library automatically downloads and manages the underlying BrowserStack Local binary. Network issues, restrictive firewalls, or insufficient file permissions can prevent successful download or corrupt the binary, leading to connection failures.
gotchaMultiple Local instances: Running multiple instances of BrowserStack Local without unique `localIdentifier`s will cause older connections to drop, leading to unstable tests or connection failures.
gotchaIncorrect `binary_path` option: While `v1.2.2` addressed issues with the `binary_path` option, incorrectly configuring it or pointing to an inaccessible path can still prevent the local tunnel from starting.
gotchaEnvironment variable for access key: Prior to `v1.1.0`, there were known issues with environment variable handling for the `BROWSERSTACK_ACCESS_KEY`, which could lead to authentication failures.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources