Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Integrate BrowserStack Automate with Concourse CI
A step-by-step guide to help you integrate Concourse CI with the BrowserStack device cloud for running all your Selenium tests on BrowserStack Automate.
Concourse is an open-source continuous integration tool. Built on the simple mechanics of resources, tasks, and jobs, Concourse presents a general approach to automation that makes it great for CI/CD.
The pipeline runs, and the test result is also displayed on your Concourse Dashboard page.
Integrate existing test cases
With existing test cases, integrating BrowserStack involves editing your test cases to add BrowserStack capabilities, credentials, and, remote URL.
Though your existing test scripts include capabilities, BrowserStack also provides specific capabilities that help determine how tests are run. The following example code snippet sets the build name, declares Access Key and Username as environment variables, and creates a remote driver connection.
Using the default BUILD_JOB_NAME or BUILD_NAME environment variables in the BrowserStack build name helps generate a unique build name for every test run. To learn more about this environment variable, check out the Concourse task metadata page.
Set capabilities using the following code snippet:
username=ENV['BROWSERSTACK_USERNAME']accessKey=ENV['BROWSERSTACK_ACCESS_KEY']buildName=ENV['BUILD_NAME']# to run on Chromeoptions=Selenium::WebDriver::Options.chromecapabilities={'bstack:options'=>{"buildName"=>"BStack Build Number: "+buildName,"seleniumVersion"=>"4.0.0",},}options.add_option('bstack:options',bstack_options)driver=Selenium::WebDriver.for(:remote,:url=>"https://"+username+":"+accessKey+"@hub.browserstack.com/wd/hub",:capabilities=>options)
Stringusername=Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME");StringaccessKey=Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY");StringbuildName=Environment.GetEnvironmentVariable("BUILD_NAME");OpenQA.Selenium.Chrome.ChromeOptionscapability=newOpenQA.Selenium.Chrome.ChromeOptions();capability.AddAdditionalCapability("name","BStack-[C_sharp] Sample Test",true);// test namecapability.AddAdditionalCapability("build","BStack Build Number: "+buildName,true);// CI/CD job or build namecapability.AddAdditionalCapability("browserstack.user",username,true);capability.AddAdditionalCapability("browserstack.key",accessKey,true);driver=newRemoteWebDriver(newUri("https://hub.browserstack.com/wd/hub/"),capability);
$username=getenv('BROWSERSTACK_USERNAME');$accessKey=getenv('BROWSERSTACK_ACCESS_KEY');$buildName=getenv('BUILD_NAME');$caps=array("build"=>"BStack Build Number: ".$buildName,// CI/CD job or build name);$web_driver=RemoteWebDriver::create("https://".$username.":".$accessKey."@hub.browserstack.com/wd/hub",$caps);
username=os.environ.get('BROWSERSTACK_USERNAME')accessKey=os.environ.get('BROWSERSTACK_ACCESS_KEY')buildName=os.environ.get('BUILD_NAME')desired_cap={'build':"BStack Build Number: "+buildName,# CI/CD job or build name
'browserstack.user':username,'browserstack.key':accessKey,}driver=webdriver.Remote(command_executor='https://hub.browserstack.com/wd/hub',desired_capabilities=desired_cap)
username=ENV['BROWSERSTACK_USERNAME']accessKey=ENV['BROWSERSTACK_ACCESS_KEY']buildName=ENV['BUILD_NAME']caps=Selenium::WebDriver::Remote::Capabilities.newcaps['build']='BStack Build Number: '+buildName# CI/CD job or build namedriver=Selenium::WebDriver.for(:remote,:url=>"https://"+username+":"+accessKey+"@hub.browserstack.com/wd/hub",:desired_capabilities=>caps)
Integrate test cases for privately hosted websites
If you are testing websites hosted locally as part of your testing or development environment, you need to configure your Concourse pipeline to use the Local testing.
Using the Local testing feature of BrowserStack, remote browsers at the BrowserStack cloud can access websites hosted on your private or internal networks. To learn more about how Local testing works, check out the Local testing guide.
Apart from setting up a Local connection, you must also add the browserstack.local capability in your test scripts.
Using Local binary, the remote browsers in the BrowserStack cloud can access your private or locally-hosted website through the connection established between BrowserStack and the Local binary running on your machine.
To create Concourse pipeline that uses BrowserStack Local, complete the following steps:
Under the run section in the .yml file, along with the commands that your tests need to run, add the following commands based on your OS.
These commands use the --daemon start and --daemon stop flags to start and stop the Local binary, respectively. To learn about additional flags used in running Local binary, check out the Binary parameter guide.
# For Linux-based systems, add the following commands to download the binary, run it, and stop its execution after the test has been executed.-wget "https://local-downloads.browserstack.com/BrowserStackLocal-linux-x64.zip"-unzip BrowserStackLocal-linux-x64.zip-./BrowserStackLocal --key $BROWSERSTACK_ACCESS_KEY --daemon start-<your-test-command>-./BrowserStackLocal --key $BROWSERSTACK_ACCESS_KEY --daemon stop# For macOS-based systems, add the following commands to download the binary, run it, and stop its execution after the test has been executed.-wget "https://local-downloads.browserstack.com/BrowserStackLocal-darwin-x64.zip"-unzip BrowserStackLocal-darwin-x64.zip-./BrowserStackLocal --key $BROWSERSTACK_ACCESS_KEY --daemon start-<your-test-command>-./BrowserStackLocal --key $BROWSERSTACK_ACCESS_KEY --daemon stop# For Windows-based systems, add the following commands to download the binary, run it, and stop its execution after the test has been executed.-wget "https://local-downloads.browserstack.com/BrowserStackLocal-win32.zip"-powershell.exe Expand-Archive BrowserStackLocal-win32.zip-./BrowserStackLocal-win32/BrowserStackLocal.exe --key %BROWSERSTACK_ACCESS_KEY% --daemon start-<your-test-command>-./BrowserStackLocal-win32/BrowserStackLocal.exe --key %BROWSERSTACK_ACCESS_KEY% --daemon stop
Save the changes made to the .yml file.
Note: To download another Local binary version, check out the releases and downloads section.
If you prefer to manage the Local connection through your test scripts, you can use the language bindings.
Note: Ensure that you complete the steps mentioned in the set up Concourse pipeline section to create your Concourse pipeline.
Apart from these configurations, you can set other Local options, such as, testing behind a proxy, folder testing, or using multiple local instances. Check out Introduction to Local Testing for more information.
Add browserstack.local capability to test scripts
Add the browserstack.local capability to test scripts using the following code snippets. When you set this capability to true, BrowserStack resolves the request via the Local agent running in your network.