Selenium tests

Selenium tests

Selenium is a set of tools for browser testing automation. With Buddy dedicated service you can run Selenium tests directly in Buddy.

Pipeline configuration

First, you need to add a project and a Git repository that you want to test. You can synchronize Buddy with GitHub, Bitbucket or GitLab, or attach any Git repository of your choice. Adding a new Buddy projectAdding a new Buddy project

The next step is to add a pipeline and define when and for which branches it should run. You can run your tests after every push to the repository, at a specific time of a day, or before the deployment to the server. Adding a new pipelineAdding a new pipeline

Now it’s time to add a build action which will run your tests. As the environment, select one of the predefined build actions. Buddy supports all popular languages, frameworks and build tools, from PHP to Node, Python, Rails, Gulp and more: Buddy build actionsBuddy build actions

In each build action you can customize the environment for your app and define the commands to run: Default Gulp build commandsDefault Gulp build commands

Selenium is available as an attachable microservice in the Services tab. You can choose either the Chrome or the Firefox driver: Adding test serviceAdding test service

After adding the service, copy its hostname and paste it to the Selenium configuration file in your repository: Selenium service configurationSelenium service configuration

Here's an example for the WebdriverIO file:

  # Node.js + WebdriverIO example
     desiredCapabilities: {
     browserName : 'chrome'
     host: 'selenium-ch',
     port: 4444

BrowserStack integration

If you want to run advanced Selenium tests in parallel on multiple browsers, we recommend to use BrowserStack. Configuration is very easy and requires adding a couple of environment variables in Buddy:

        BS_AUTOMATE_PROJECT: "Buddy Tests"

Creating variablesCreating variables

Once you add the variables, you can use them in the config file for your tests. The example below shows how to do it for Ruby's Cucumber framework:

require 'selenium/webdriver'

  url = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}"

  capabilities =

  capabilities['project'] = ENV['BS_AUTOMATE_PROJECT'] if ENV['BS_AUTOMATE_PROJECT']
  capabilities['build'] = ENV['BS_AUTOMATE_BUILD'] if ENV['BS_AUTOMATE_BUILD']

  capabilities['platform'] = ENV['SELENIUM_PLATFORM'] || 'ANY'
  capabilities['browser'] = ENV['SELENIUM_BROWSER'] || 'chrome'
  capabilities['browser_version'] = ENV['SELENIUM_VERSION'] if ENV['SELENIUM_VERSION']

  browser = Selenium::WebDriver.for(:remote, :url => url, :desired_capabilities => capabilities)

  Before do |scenario|
  @browser = browser

  at_exit do

See also

Environment variables
Run tests after every push
Continuous Deployment pipeline
Sign up for Buddy Digest

Best practices on CI/CD and fresh changelogs delivered weekly to your inbox.