Circle CI Automated Testing
Circle CI is a continuous integration service in the cloud.
It is very easy to use the TestingBot Selenium grid together with Circle CI.
Below are the steps to run your Selenium tests via Circle CI, once the tests are up and running you can even display a TestingBot Status badge showcasing your Selenium tests status.
Get Circle CI up and running
Sign up at Circle CI and connect your project with Circle CI."
Example circle.yml file:
machine:
ruby:
version: 2.0.0-p0
environment:
SELENIUM_HOST: hub.testingbot.com
SELENIUM_PORT: 80
TB_AUTOMATE_PROJECT: "Run on circleCI"
TB_AUTOMATE_BUILD: "build No. $CIRCLE_BUILD_NUM for circleCI"
SELENIUM_PLATFORM: WINDOWS
SELENIUM_BROWSER: IE
SELENIUM_VERSION: 9
test:
override:
- bundle exec cucumber
We recommend that you save your TestingBot Key and Secret via the Circle web interface.
This makes sure your credentials are not available to anyone else.
Once you've saved your Key and Secret, you can access them via Environment Variables, for example if you saved them under the name TB_KEY
and TB_SECRET
:
require 'selenium/webdriver'
url = "http://#{ENV['TB_KEY']}:#{ENV['TB_SECRET']}@hub.testingbot.com/wd/hub"
capabilities = Selenium::WebDriver::Remote::Capabilities.new
capabilities['project'] = ENV['TB_AUTOMATE_PROJECT'] if ENV['TB_AUTOMATE_PROJECT']
capabilities['build'] = ENV['TB_AUTOMATE_BUILD'] if ENV['TB_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
end
at_exit do
browser.quit
end