Skip to content

Commit 2f4c1fb

Browse files
committed
Added initial draft for browserstack add-on.
1 parent 76618ac commit 2f4c1fb

File tree

3 files changed

+136
-1
lines changed

3 files changed

+136
-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

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
[local-testing]: https://www.browserstack.com/local-testing
14+
[open-source-browserstack]: https://www.browserstack.com/pricing
15+
[account-settings]: https://www.browserstack.com/accounts/settings
16+
[encryption-keys]: http://docs.travis-ci.com/user/encryption-keys/
17+
[browserstack-ruby-bindings]: https://www.browserstack.com/automate/ruby
18+
[travis-matrix-builds]: https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix
19+
20+
## Setting up BrowserStack
21+
22+
[BrowserStack Local Testing][local-testing] establishes a secure connection between your Travis build container/VM
23+
and BrowserStack servers. Local Testing also has support for firewalls, proxies and Active Directory.
24+
Once the secure connection is setup, all URLs work out of the box, including your webserver, local folders, as well as
25+
URLs with HTTPS.
26+
27+
Before you move ahead 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 will be required in configuring
30+
your projects .travis.yml file.
31+
32+
Choose whether you want to store your access key as plain text or in secure/encrypted form. For open source projects we recommend
33+
storing the access key in 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+
37+
### Plain Text Access Key
38+
39+
40+
To keep your access key in plain text add the following configuration to your .travis.yml file,
41+
42+
addons:
43+
browserstack:
44+
username: "Your BrowserStack username"
45+
access_key: "Your BrowserStack access key"
46+
47+
48+
Note, this keeps your access key in plain text and other users that have access to your repository can read and use
49+
the same access key to test on BrowserStack. If you want to prevent this you can encrypt your access key as explained below.
50+
51+
### Encrypted Access Key
52+
53+
To encrypt your access key for use in .travis.yml you can encrypt it using `travis encrypt "your BrowserStack access key"`.
54+
You need to have the travis cli installed to be able to do this (see [Encryption Keys][encryption-keys] for more details).
55+
Once your access key is encrypted you can add the secure string as,
56+
57+
addons:
58+
browserstack: "Your BrowserStack username"
59+
access_key:
60+
secure: "The secure string output of `travis encrypt`"
61+
62+
63+
### Local Identifier
64+
65+
A Local identifier is a unique identifier for each Local connection when multiple Local connections are connected.
66+
The add-on will **ALWAYS** create a local identifier for each local connection that is created,
67+
this local identifier MUST be added to the Selenium capabilities if Selenium is the testing framework being used.
68+
The local identifier is exposed as an environment variable `BROWSERSTACK_LOCAL_IDENTIFIER`. You can use this to set
69+
Selenium capabilities as, using Ruby's [selenium-webdriver][browserstack-ruby-bindings]
70+
71+
require 'rubygems'
72+
require 'selenium-webdriver'
73+
74+
# Input capabilities
75+
caps = Selenium::WebDriver::Remote::Capabilities.new
76+
caps['browserstack.local'] = 'true'
77+
caps['browserstack.localIdentifier'] = ENV['BROWSERSTACK_LOCAL_IDENTIFIER']
78+
# Add other capabilities like browser name, version and os name, version
79+
...
80+
81+
driver = Selenium::WebDriver.for(:remote,
82+
:url => "http://USERNAME:[email protected]/wd/hub",
83+
:desired_capabilities => caps)
84+
85+
Local identifiers are essential for [matrix builds][travis-matrix-builds]. Matrix builds in travis can be run on
86+
the same VM so to ensure that the correct local tunnel gets the correct requests we need to add the Local identifier
87+
when starting the connection.
88+
89+
### Folder Testing
90+
91+
Local testing also allows you to test HTML in local folders. To enable folder testing you need to set the
92+
name of the local folders as,
93+
94+
addons:
95+
browserstack: "Your BrowserStack username"
96+
access_key:
97+
secure: "The secure string output of `travis encrypt`"
98+
folder: "Absolute path of the folder containing HTML files"
99+
100+
You can then access the HTML files via the url
101+
`http://$BROWSERSTACK_USERNAME.browserstack.com/"Path to your HTML file with respect to the folder set."`
102+
103+
104+
### Other Options
105+
106+
Other options that are supported by the add on are,
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+
Example,
111+
112+
addons:
113+
browserstack: "Your BrowserStack username"
114+
access_key:
115+
secure: "The secure string output of `travis encrypt`"
116+
force_local: 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.
120+
121+
### Proxy Options
122+
123+
Local testing also allows you to set the proxy host, port, username and password through which all
124+
urls will be resolved. You can set proxy settings as follows,
125+
126+
addons:
127+
browserstack: "Your BrowserStack username"
128+
access_key:
129+
secure: "The secure string output of `travis encrypt`"
130+
proxy_host: "Proxy server host"
131+
proxy_port: "Proxy server port"
132+
proxy_user: "User to use when accessing proxy server"
133+
proxy_pass: "Password to use when accessing proxy server"
134+

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)