Skip to content

Commit fb9c050

Browse files
committed
updated readme
1 parent 518b8ae commit fb9c050

File tree

1 file changed

+104
-25
lines changed

1 file changed

+104
-25
lines changed

README.md

Lines changed: 104 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,123 @@
22

33
[![Build Status](https://travis-ci.org/browserstack/browserstack-local-python.svg?branch=master)](https://travis-ci.org/browserstack/browserstack-local-python)
44

5-
## Setup
5+
A simple Python wrapper for BrowserStack Local Binary.
6+
7+
## Installation
68

79
```
810
pip install browserstack-local
911
```
1012

11-
## API
13+
## Example
14+
15+
```
16+
from browserstack.local import Local
17+
18+
#creates an instance of Local
19+
bs_local = Local()
20+
21+
#replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
22+
bs_local_args = { "key": "<browserstack-accesskey>" }
23+
24+
#starts the Local instance with the required arguments
25+
bs_local.start(**bs_local_args)
26+
27+
#check if BrowserStack local instance is running
28+
print bs_local.isRunning()
29+
30+
#stop the Local instance
31+
bs_local.stop()
32+
33+
```
34+
35+
## Arguments
1236

13-
### Constructor
37+
Apart from the key, all other BrowserStack Local modifiers are optional. For the full list of modifiers, refer [BrowserStack Local modifiers](https://www.browserstack.com/local-testing#modifiers). For examples, refer below -
1438

15-
* `browserstack.Local()`: creates an instance of Local
39+
#### Verbose Logging
40+
To enable verbose logging -
41+
```
42+
bs_local_args = { "key": "<browserstack-accesskey>" , "v": "true"}
43+
```
1644

17-
### Methods
45+
#### Folder Testing
46+
To test local folder rather internal server, provide path to folder as value of this option -
47+
```
48+
bs_local_args = { "key": "<browserstack-accesskey>" , "f": "/my/awesome/folder"}
49+
```
1850

19-
* `start(**options)`: starts Local instance with options. The options available are detailed below.
20-
* `stop()`: stops the Local instance
21-
* `isRunning()`: checks if Local instance is running
51+
#### Force Start
52+
To kill other running Browserstack Local instances -
53+
```
54+
bs_local_args = { "key": "<browserstack-accesskey>" , "force": "true"}
55+
```
2256

23-
### Options
57+
#### Only Automate
58+
To disable local testing for Live and Screenshots, and enable only Automate -
59+
```
60+
bs_local_args = { "key": "<browserstack-accesskey>" , "onlyAutomate": "true"}
61+
```
2462

25-
* `key`: BrowserStack Access Key
26-
* `v`: Provides verbose logging
27-
* `f`: If you want to test local folder rather internal server, provide path to folder as value of this option
28-
* `force`: Kill other running Browserstack Local
29-
* `only`: Restricts Local Testing access to specified local servers and/or folders
30-
* `forcelocal`: Route all traffic via local machine
31-
* `onlyAutomate`: Disable Live Testing and Screenshots, just test Automate
32-
* `proxyHost`: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
33-
* `proxyPort`: Port for the proxy, defaults to 3128 when -proxyHost is used
34-
* `proxyUser`: Username for connecting to proxy (Basic Auth Only)
35-
* `proxyPass`: Password for USERNAME, will be ignored if USERNAME is empty or not specified
36-
* `localIdentifier`: If doing simultaneous multiple local testing connections, set this uniquely for different processes
37-
* `hosts`: List of hosts and ports where Local must be enabled for eg. localhost,3000,1,localhost,3001,0
38-
* `logfile`: Path to file where Local logs be saved to
39-
* `binarypath`: Optional path to Local binary
63+
#### Force Local
64+
To route all traffic via local(your) machine -
65+
```
66+
bs_local_args = { "key": "<browserstack-accesskey>" , "forcelocal": "true"}
67+
```
4068

69+
#### Proxy
70+
To use a proxy for local testing -
4171

42-
## Tests
72+
* proxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
73+
* proxyPort: Port for the proxy, defaults to 3128 when -proxyHost is used
74+
* proxyUser: Username for connecting to proxy (Basic Auth Only)
75+
* proxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
76+
77+
```
78+
bs_local_args = { "key": "<browserstack-accesskey>", "proxyHost": "127.0.0.1", "proxyPort": "8000", "proxyUser": "user", "proxyPass": "password"}
79+
```
80+
81+
#### Local Identifier
82+
If doing simultaneous multiple local testing connections, set this uniquely for different processes -
83+
```
84+
bs_local_args = { "key": "<browserstack-accesskey>" , "localIdentifier": "randomstring"}
85+
```
86+
87+
## Additional Arguments
88+
89+
#### Binary Path
90+
91+
By default, BrowserStack local wrappers try downloading and executing the latest version of BrowserStack binary in ~/.browserstack or the present working directory or the tmp folder by order. But you can override these by passing the -binarypath argument.
92+
Path to specify local Binary path -
93+
```
94+
bs_local_args = { "key": "<browserstack-accesskey>" , "binarypath": "/browserstack/BrowserStackLocal"}
95+
```
96+
97+
#### Logfile
98+
To save the logs to the file while running with the '-v' argument, you can specify the path of the file. By default the logs are saved in the local.log file in the present woring directory.
99+
To specify the path to file where the logs will be saved -
100+
```
101+
bs_local_args = { "key": "<browserstack-accesskey>" , "v": "true", "logfile": "/browserstack/logs.txt"}
102+
```
103+
104+
## Contribute
105+
106+
### Build Instructions
43107

44108
To run the test suite run, `python -m unittest discover`.
45109

110+
### Reporting bugs
111+
112+
You can submit bug reports either in the Github issue tracker.
113+
114+
Before submitting an issue please check if there is already an existing issue. If there is, please add any additional information give it a "+1" in the comments.
115+
116+
When submitting an issue please describe the issue clearly, including how to reproduce the bug, which situations it appears in, what you expect to happen, what actually happens, and what platform (operating system and version) you are using.
117+
118+
### Pull Requests
119+
120+
We love pull requests! We are very happy to work with you to get your changes merged in, however, please keep the following in mind.
121+
122+
* Adhere to the coding conventions you see in the surrounding code.
123+
* Include tests, and make sure all tests pass.
124+
* Before submitting a pull-request, clean up the git history by going over your commits and squashing together minor changes and fixes into the corresponding commits. You can do this using the interactive rebase command.

0 commit comments

Comments
 (0)