|
1 | 1 | A command line interface to run browser tests over BrowserStack. |
2 | 2 |
|
3 | | -## Install |
4 | | -Go to the `browserstack-runner` directory. |
5 | | -Install browserstack-runner |
| 3 | +## Usage |
6 | 4 |
|
7 | | - npm -g install |
| 5 | +Install globally: |
8 | 6 |
|
9 | | -or |
| 7 | + npm -g install browserstack-runner |
10 | 8 |
|
| 9 | +Then, after setting up the configuration, run tests with: |
11 | 10 |
|
12 | | -For development, |
| 11 | + browserstack-runner |
13 | 12 |
|
14 | | - npm link |
| 13 | +You can also install locally and run the local binary: |
15 | 14 |
|
16 | | -## Configuration |
17 | | -To run browser tests on BrowserStack infrastructure, you need to |
18 | | -create a `browserstack.json` file in project's root directory (the |
19 | | -directory from which tests are run), by running this command: |
20 | | - |
21 | | - browserstack-runner init [preset] |
22 | | - |
23 | | -If nothing is provided as `preset` **default** is used. |
24 | | - |
25 | | -> Currently only one preset is present: **default** |
| 15 | + npm install browserstack-runner |
| 16 | + node_modules/.bin/browserstack-runner |
26 | 17 |
|
27 | | -### Parameters |
28 | | - |
29 | | - - *username*: BrowserStack username |
30 | | - (Alternatively: use `BROWSERSTACK_USERNAME` environment variable) |
31 | | - |
32 | | - - *key*: BrowserStack key |
33 | | - (Alternatively: use `BROWSERSTACK_KEY` environment variable) |
| 18 | +## Configuration |
34 | 19 |
|
35 | | - - *test_path*: Path to the which will execute the tests when opened |
36 | | - in a browser. |
| 20 | +To run browser tests on BrowserStack infrastructure, you need to create a `browserstack.json` file in project's root directory (the directory from which tests are run), by running this command: |
37 | 21 |
|
38 | | - - *test_framework*: Specify test framework which will execute the tests. |
39 | | - We support qunit, jasmine, jasmine 2.0 and mocha. |
| 22 | + browserstack-runner init |
40 | 23 |
|
41 | | - - *timeout*: Specify worker timeout with BrowserStack. |
| 24 | +### Parameters for `browserstack.json` |
42 | 25 |
|
43 | | - - *browsers*: A list of browsers on which tests are to be run. |
| 26 | + * `username`: BrowserStack username (Or `BROWSERSTACK_USERNAME` environment variable) |
| 27 | + * `key`: BrowserStack [access key](https://www.browserstack.com/accounts/local-testing) (Or `BROWSERSTACK_KEY` environment variable) |
| 28 | + * `test_path`: Path to the test page which will run the tests when opened in a browser. |
| 29 | + * `test_framework`: Specify test framework which will run the tests. Currently supporting qunit, jasmine, jasmine2 and mocha. |
| 30 | + * `timeout`: Specify worker timeout with BrowserStack. |
| 31 | + * `browsers`: A list of browsers on which tests are to be run. Find a [list of all supported browsers and platforms on browerstack.com](http://www.browserstack.com/list-of-browsers-and-platforms?product=live). |
| 32 | + * `proxy`: Specify a proxy to use for the local tunnel. Object with `host`, `port`, `username` and `password` properties. |
44 | 33 |
|
45 | | -A sample configuration file (list: http://www.browserstack.com/list-of-browsers-and-platforms?product=live): |
| 34 | +A sample configuration file: |
46 | 35 |
|
47 | 36 | ```json |
48 | 37 | { |
49 | 38 | "username": "<username>", |
50 | | - "key": "<key>", |
51 | | - "test_framework": "qunit/jasmine/jasmine2/mocha", |
| 39 | + "key": "<access key>", |
| 40 | + "test_framework": "qunit|jasmine|jasmine2|mocha", |
52 | 41 | "test_path": ["relative/path/to/test/page1", "relative/path/to/test/page2"], |
53 | | - "browsers": [{ |
54 | | - "browser": "firefox", |
55 | | - "browser_version": "15.0", |
56 | | - "device": null, |
57 | | - "os": "OS X", |
58 | | - "os_version": "Snow Leopard" |
59 | | - }, |
60 | | - { |
61 | | - "browser": "firefox", |
62 | | - "browser_version": "16.0", |
63 | | - "device": null, |
64 | | - "os": "Windows", |
65 | | - "os_version": "7" |
66 | | - }, |
67 | | - { |
68 | | - "browser": "firefox", |
69 | | - "browser_version": "17.0", |
70 | | - "device": null, |
71 | | - "os": "Windows", |
72 | | - "os_version": "8" |
73 | | - }, |
74 | | - { |
75 | | - "browser": "ie", |
76 | | - "browser_version": "8.0", |
77 | | - "device": null, |
78 | | - "os": "Windows", |
79 | | - "os_version": "7" |
80 | | - }, |
81 | | - { |
82 | | - "browser": "ie", |
83 | | - "browser_version": "9.0", |
84 | | - "device": null, |
85 | | - "os": "Windows", |
86 | | - "os_version": "7" |
87 | | - }, |
88 | | - { |
89 | | - "os": "android", |
90 | | - "os_version": "4.0", |
91 | | - "device": "Samsung Galaxy Nexus" |
92 | | - }, |
93 | | - { |
94 | | - "os": "ios", |
95 | | - "os_version": "7.0", |
96 | | - "device": "iPhone 5S" |
97 | | - }, |
98 | | - { |
99 | | - "browser": "ie", |
100 | | - "browser_version": "10.0", |
101 | | - "device": null, |
102 | | - "os": "Windows", |
103 | | - "os_version": "8" |
104 | | - }] |
105 | | -} |
106 | | -``` |
107 | | - |
108 | | -#### Compact `browsers` configuration |
109 | | - |
110 | | -Alternatively, if `os` and `os_version` granularity is not desired, following configuration can be used: |
111 | | -- *browser*_current or *browser*_latest: will assign the latest version of the *browser*. |
112 | | -- *browser*_previous: will assign the previous version of the *browser*. |
113 | | -- *browser*_*version*: will assign the *version* specificed of the *browser*. Minor versions can be concatinated with underscore. |
114 | | - |
115 | | -Example: |
116 | | -```json |
117 | | -"browsers": [ |
118 | | - "chrome_previous", |
119 | | - "chrome_latest", |
120 | | - "firefox_previous", |
121 | | - "firefox_latest", |
122 | | - "ie_6", |
123 | | - "ie_11", |
124 | | - "opera_12_1", |
125 | | - "safari_5_1", |
| 42 | + "browsers": [ |
126 | 43 | { |
127 | 44 | "browser": "ie", |
128 | 45 | "browser_version": "10.0", |
129 | 46 | "device": null, |
130 | 47 | "os": "Windows", |
131 | 48 | "os_version": "8" |
| 49 | + }, |
| 50 | + { |
| 51 | + "os": "android", |
| 52 | + "os_version": "4.0", |
| 53 | + "device": "Samsung Galaxy Nexus" |
| 54 | + }, |
| 55 | + { |
| 56 | + "os": "ios", |
| 57 | + "os_version": "7.0", |
| 58 | + "device": "iPhone 5S" |
132 | 59 | } |
133 | | -] |
| 60 | + ] |
| 61 | +} |
134 | 62 | ``` |
135 | 63 |
|
136 | | -### Enviroment variables |
137 | | - |
138 | | -* `BROWSERSTACK_USERNAME`: |
139 | | -BrowserStack user name. |
| 64 | +#### Compact `browsers` configuration |
140 | 65 |
|
141 | | -* `BROWSERSTACK_KEY`: |
142 | | -BrowserStack key. |
| 66 | +When `os` and `os_version` granularity is not desired, following configuration can be used: |
| 67 | + * `[browser]_current` or *browser*_latest: will assign the latest version of the *browser*. |
| 68 | + * `[browser]_previous`: will assign the previous version of the *browser*. |
| 69 | + * `[browser]_[version]`: will assign the *version* specificed of the *browser*. Minor versions can be concatinated with underscores. |
143 | 70 |
|
144 | | -* `TUNNEL_ID`: |
145 | | -Identifier for the current instance of the tunnel process. In `TRAVIS` setup `TRAVIS_JOB_ID` will be the default identifier. |
| 71 | +This can also be mixed with fine-grained configuration. |
146 | 72 |
|
147 | | -* `BROWSERSTACK_JSON`: |
148 | | -Path to the browserstack.json file. If null, `browserstack.json` in the root directory will be used. |
| 73 | +Example: |
| 74 | +```json |
| 75 | +{ |
| 76 | + "browsers": [ |
| 77 | + "chrome_previous", |
| 78 | + "chrome_latest", |
| 79 | + "firefox_previous", |
| 80 | + "firefox_latest", |
| 81 | + "ie_6", |
| 82 | + "ie_11", |
| 83 | + "opera_12_1", |
| 84 | + "safari_5_1", |
| 85 | + { |
| 86 | + "browser": "ie", |
| 87 | + "browser_version": "10.0", |
| 88 | + "device": null, |
| 89 | + "os": "Windows", |
| 90 | + "os_version": "8" |
| 91 | + } |
| 92 | + ] |
| 93 | +} |
| 94 | +``` |
149 | 95 |
|
150 | 96 | ### Proxy support for BrowserStack local |
| 97 | + |
151 | 98 | Add the following in `browserstack.json` |
152 | 99 | ```json |
153 | | -... |
154 | | -"proxy": { |
155 | | - "host": "localhost", |
156 | | - "port": 3128, |
157 | | - "username": "foo", |
158 | | - "password": "bar" |
| 100 | +{ |
| 101 | + "proxy": { |
| 102 | + "host": "localhost", |
| 103 | + "port": 3128, |
| 104 | + "username": "foo", |
| 105 | + "password": "bar" |
| 106 | + } |
159 | 107 | } |
160 | | -... |
161 | 108 | ``` |
162 | 109 |
|
163 | | -### Secure Information |
| 110 | +### Supported environment variables |
| 111 | + |
| 112 | +To avoid duplication of system or user specific information across several configuration files, use these environment variables: |
164 | 113 |
|
165 | | -To prevent checking in the BrowserStack `username` and `key` in your |
166 | | -source control, the corresponding environment variables can be used. |
| 114 | +* `BROWSERSTACK_USERNAME`: BrowserStack user name. |
| 115 | +* `BROWSERSTACK_KEY`: BrowserStack key. |
| 116 | +* `TUNNEL_ID`: Identifier for the current instance of the tunnel process. In `TRAVIS` setup `TRAVIS_JOB_ID` will be the default identifier. |
| 117 | +* `BROWSERSTACK_JSON`: Path to the browserstack.json file. If null, `browserstack.json` in the root directory will be used. |
167 | 118 |
|
168 | | -The environment variables then can be safely provided in the build |
169 | | -configuration. For example, with travis-ci you can follow: |
170 | 119 |
|
171 | | -http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables |
| 120 | +### Secure Information |
172 | 121 |
|
173 | | -## Running tests |
174 | | -Run `browserstack-runner` to run the tests on all the browsers mentioned |
175 | | -in the configuration. |
| 122 | +To avoid checking in the BrowserStack `username` and `key` in your source control system, the corresponding environment variables can be used. |
176 | 123 |
|
177 | | -You can include this in your test script to automatically run cross |
178 | | -browser tests on every build. |
| 124 | +These can also be provided by a build server, for example [using secure environment variables on Travis CI](http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables). |
0 commit comments