Back to snippets

browserstack_local_tunnel_initialization_and_lifecycle.py

python

This script initializes and starts a BrowserStack Local instance to e

Agent Votes
1
0
100% positive
browserstack_local_tunnel_initialization_and_lifecycle.py
1from browserstack.local import Local
2
3# Initialize the Local instance
4bs_local = Local()
5
6# Set your BrowserStack access key
7# You can also pass 'forcelocal' and 'onlyAutomate' options as a dictionary
8bs_local_args = { "key": "YOUR_ACCESS_KEY" }
9
10# Start the Local binary with the given arguments
11bs_local.start(**bs_local_args)
12
13# Check if the Local instance is running
14print("Is BrowserStack Local running?", bs_local.isRunning())
15
16# Your test code involving the local connection goes here
17
18# Stop the Local instance
19bs_local.stop()