Search by

Selenium with Cucumber

Getting started on BrowserStack with Cucumber

Get Started

Note: This tutorial requires browserstack-automate integration for Ruby.

BrowserStack supports Selenium automated tests using Cucumber.

Please ensure that Cucumber is available.

gem install cucumber

Running First Test

You can use the browserstack-automate integration to run your Cucumber tests on BrowserStack. It’s a simple two-step process:

Step 1 - Install ‘browserstack-automate’ integration

gem install browserstack-automate

Step 2 - Add it to your support/env.rb file

You just need to add this to your configuration file

require 'browserstack-automate'
BrowserStack.for "cucumber"

Rest of configuration file remains the same

# Enabling browserstack-automate ruby integration
require 'browserstack-automate'
BrowserStack.for "cucumber"

# Rest of the configuration file remains unchanged
browser = Selenium::WebDriver.for :firefox

Before do |scenario|
  @browser = browser
end

at_exit do
  browser.quit
end

That’s it! You can now execute your tests on BrowserStack by using the RUN_ON_BSTACK, BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables.

RUN_ON_BSTACK=true BROWSERSTACK_USERNAME=YOUR_USERNAME BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY bundle exec cucumber