Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Integrate BrowserStack Automate with CircleCI
A step-by-step guide to help you integrate CircleCI with the BrowserStack device cloud for running all your Selenium tests on BrowserStack Automate.
CircleCI uses .circleci/config.yml for configuration (read more about CircleCI), and it can be used to integrate your tests with BrowserStack. There are some variables you need to set: grid config, username, access key etc. For more detailed information on setting environment variables in CircleCI, please refer to their documentation.
Setting the variables
BrowserStack recommends you encrypt variables like username and access key. CircleCI enables the user to secure environment variables via their web interface. This functionality allows you to keep the contents of the secure variable private.
The key-value pairs are set in the project settings, which can be found under Tweaks, in the Environment variables section. Public environment variables can be set directly via circle.yml in machine section, under environment.
Shown below is a sample configuration for the circle.yml file:
username=ENV['BROWSERSTACK_USERNAME']accessKey=ENV['BROWSERSTACK_ACCESS_KEY']local=ENV['BROWSERSTACK_LOCAL']localIdentifier=ENV['BROWSERSTACK_LOCAL_IDENTIFIER']# to run on Chromeoptions=Selenium::WebDriver::Options.chromecapabilities={'bstack:options'=>{"os"=>"Windows","local"=local,"localIdentifier"=localIdentifier,},"browserName"=>"Chrome",}options.add_option('bstack:options',bstack_options)driver=Selenium::WebDriver.for(:remote,:url=>"https://"+username+":"+accessKey+"@hub.browserstack.com/wd/hub",:capabilities=>options)
While testing on development or staging environments, you can do the following:
Configure CircleCI to automatically download the latest version of the BrowserStack Local binary.
Instantiate the binary before your test starts.
Enable Local Testing by setting the local capability to true in your test script.
Refer to the sample code below:
machine:environment:BROWSERSTACK_USERNAME:"YOUR_USERNAME"BROWSERSTACK_ACCESS_KEY:"YOUR_ACCESS_KEY"BROWSERSTACK_LOCAL:truetest:pre:# Download the browserstack binary file-wget "https://local-downloads.browserstack.com/BrowserStackLocal-linux-x64.zip"# Unzip the BrowserStack Local binary file-unzip BrowserStackLocal-linux-x64.zip# Run the file with your access key-./BrowserStackLocal $BROWSERSTACK_ACCESS_KEY:background:true
Did this page help you?
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback
Is this page helping you?
Yes
No
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked