Skip to content

Commit 2bf0efc

Browse files
author
Anirudha Khanna
authored
Merge pull request #1 from anirudha13/bstack-internal-review
Added initial draft for browserstack add-on.
2 parents 76618ac + d55582d commit 2bf0efc

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed

_includes/sidebar.html

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ <h3>Integrations and Notifications</h3>
8686
<li><a href="/user/notifications/">Configuring Notifications</a></li>
8787
<li><a href="/user/status-images/">Showing Build Status Images</a></li>
8888
<li><a href="/user/code-climate/">Code Climate</a></li>
89+
<li><a href="/user/browserstack/">BrowserStack</a></li>
8990
<li><a href="/user/sauce-connect/">Sauce Labs</a></li>
9091
<li><a href="/user/build-feeds/">Atom Feeds</a></li>
9192
<li><a href="/user/cc-menu">CCMenu / CCTray Feeds</a></li>

user/browserstack.md

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: Using BrowserStack with Travis CI
3+
layout: en
4+
permalink: /user/browserstack/
5+
---
6+
Travis CI integrates with [BrowserStack](https://www.browserstack.com), a cross browser and real device
7+
web-based testing platform. BrowserStack can be used for Live as well as automated testing through frameworks
8+
like Selenium, Karma and others.
9+
10+
This add-on automatically sets up Local Testing which allows you to test your private servers, alongside public
11+
URLs, using the BrowserStack cloud. To do this it uses the BrowserStackLocal binary for your build platform.
12+
13+
[BrowserStack Local Testing][local-testing] establishes a secure connection between your Travis build container/VM
14+
and BrowserStack servers. Local Testing also has support for firewalls, proxies and Active Directory.
15+
Once the secure connection is setup, all URLs work out of the box, including your webserver, local folders, as well as
16+
URLs with HTTPS.
17+
18+
[local-testing]: https://www.browserstack.com/local-testing
19+
[open-source-browserstack]: https://www.browserstack.com/pricing
20+
[account-settings]: https://www.browserstack.com/accounts/settings
21+
[encryption-keys]: http://docs.travis-ci.com/user/encryption-keys/
22+
[browserstack-ruby-bindings]: https://www.browserstack.com/automate/ruby
23+
[travis-matrix-builds]: https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix
24+
25+
## Setting up BrowserStack
26+
27+
Please sign up for a BrowserStack account if you haven't already; it's
28+
[free][open-source-browserstack] for Open Source projects. Once you have signed up get your username and access key from
29+
the [account settings][account-settings] page. Your username and access key are required to configure the `.travis.yml`
30+
file of your project.
31+
32+
Choose whether you want to store your access key as plain text or in a secure/encrypted form. For open source projects we recommend
33+
storing the access key in a secure form so that pull requests cannot use the keys stored in your .travis.yml.
34+
For more information see the [pull requests page](http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests).
35+
36+
### Encrypted Access Key
37+
38+
To encrypt your access key for use in .travis.yml you can use `travis encrypt "your BrowserStack access key"`.
39+
You need to have the travis cli installed to be able to do this (see [Encryption Keys][encryption-keys] for more details).
40+
Once your access key is encrypted you can add the secure string:
41+
42+
addons:
43+
browserstack: "Your BrowserStack username"
44+
access_key:
45+
secure: "The secure string output of `travis encrypt`"
46+
47+
48+
### Plain Text Access Key
49+
50+
To store your access key in plain text format, add the following configuration to your .travis.yml file:
51+
52+
addons:
53+
browserstack:
54+
username: "Your BrowserStack username"
55+
access_key: "Your BrowserStack access key"
56+
57+
We **strongly** recommend storing your BrowserStack access keys in encrypted format, since other users that have access to your repository
58+
can read and use your plain text access keys to test on BrowserStack.
59+
60+
### Local Identifier
61+
62+
A Local Identifier is a unique identifier for each Local connection when multiple Local connections are connected.
63+
The add-on will **ALWAYS** create a Local Identifier for each local connection that is created. If you are using the Selenium
64+
testing framework, the Local Identifier must be added to the Selenium capabilities.
65+
66+
The Local Identifier is exposed as an environment variable `BROWSERSTACK_LOCAL_IDENTIFIER`. You can use it to set
67+
the Selenium capability. See the following example which uses Ruby's [selenium-webdriver][browserstack-ruby-bindings]:
68+
69+
require 'rubygems'
70+
require 'selenium-webdriver'
71+
72+
# Input capabilities
73+
caps = Selenium::WebDriver::Remote::Capabilities.new
74+
caps['browserstack.local'] = 'true'
75+
caps['browserstack.localIdentifier'] = ENV['BROWSERSTACK_LOCAL_IDENTIFIER']
76+
# Add other capabilities like browser name, version and os name, version
77+
...
78+
79+
driver = Selenium::WebDriver.for(:remote,
80+
:url => "http://USERNAME:[email protected]/wd/hub",
81+
:desired_capabilities => caps)
82+
83+
Local identifiers are essential for [matrix builds][travis-matrix-builds]. Since matrix builds in travis can be run on
84+
the same VM, we need to add the Local Identifier when starting the connection to ensure that the correct local tunnel
85+
gets the right requests.
86+
87+
## Additional Options
88+
89+
### Proxy
90+
91+
Local testing also allows you to set the proxy host, port, username and password
92+
through which all urls will be resolved:
93+
94+
addons:
95+
browserstack: "Your BrowserStack username"
96+
access_key:
97+
secure: "The secure string output of `travis encrypt`"
98+
proxyHost: "Proxy server host"
99+
proxyPort: "Proxy server port"
100+
proxyUser: "User to use when accessing proxy server"
101+
proxyPass: "Password to use when accessing proxy server"
102+
103+
104+
### More Options
105+
106+
Some other options that are supported by the add on -
107+
* **force_local**: If this is set to true then all URLs will be resolved via the Travis container that your build is running in.
108+
* **only**: restricts Local testing access to the specified local servers and/or folders.
109+
110+
Sample usage,
111+
112+
addons:
113+
browserstack: "Your BrowserStack username"
114+
access_key:
115+
secure: "The secure string output of `travis encrypt`"
116+
forcelocal: true
117+
only: dev.example.com,80,0,*.example.org,80,0
118+
119+
The format for the **only** flag is, `"Host pattern,Host Port,Flag for SSL True(1)/False(0)" and repeat.

user/pull-requests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ their builds. All data that's considered confidential will not be added to the
4242
build's environment.
4343

4444
If your build relies on these to run, for instance to run Selenium tests with
45-
Sauce Labs, your build needs to take this into account. You won't be able to run
45+
[BrowserStack](https://www.browserstack.com) or Sauce Labs, your build needs to take this into account. You won't be able to run
4646
these tests for pull requests from external contributors.
4747

4848
To work around this, you could restrict these tests only to situations where the

0 commit comments

Comments
 (0)