---
title: Bitbucket Pipelines Selenium Testing with TestingBot
description: Selenium WebDriver example with Bitbucket Pipelines
source_url:
  html: https://testingbot.com/support/integrations/ci-cd/bitbucket
  md: https://testingbot.com/support/integrations/ci-cd/bitbucket/index.md
---
# Bitbucket Pipelines WebDriver Testing

Bitbucket Pipelines makes it very easy to do Continuous Integration.

You can configure Bitbucket Pipelines by adding a `bitbucket-pipelines.yml` file to the root of your repository.

See our full [Bitbucket Pipelines example](https://bitbucket.org/testingbot/bitbucket-pipelines) to see how easy it is to use TestingBot with Bitbucket Pipelines.

## Configuration

1. Go to your Bitbucket repository settings and add the following environment variables:   
  
**TB\_KEY** : Your TestingBot Key   
**TB\_SECRET** : Your TestingBot Secret

2. Configure **bitbucket-pipelines.yml** with the example configuration below:

    image: ruby:3.2
    pipelines:
      default:
        - step:
            script:
              - apt-get update
              - apt-get install -y unzip
              - bundle install
              - bundle exec rackup -p 8001 > /dev/null &
              - ./run_local.bash
              - bundle exec rspec spec/welcome.rb
              - pkill -9 rackup

The `run_local.bash` script will download our [TestingBot Tunnel](https://testingbot.com/support/tunnel)

    #!/bin/bash -e
    
    wget https://testingbot.com/tunnel/testingbot-tunnel.jar
    java -jar testingbot-tunnel.jar ${TB_KEY} ${TB_SECRET} > /dev/null &
    sleep 10

3. Read the Bitbucket environment variables in your test. For example, with RSpec:

    require 'selenium-webdriver'
    require 'rspec'
    
    RSpec.configure do |config| config.color = true end
    
    describe "The welcome demo" do
    
      before(:all) do
        testingbot_key = ENV['TB_KEY']
        testingbot_secret = ENV['TB_SECRET']
        options = Selenium::WebDriver::Chrome::Options.new
        options.add_option('platformName', 'WIN11')
        options.add_option('browserVersion', 'latest')
        options.add_option('tb:options', {
          'build' => 'Bitbucket Pipeline',
          'name' => 'Bitbucket Pipeline'
        })
        @driver = Selenium::WebDriver.for(:remote, url: "https://#{testingbot_key}:#{testingbot_secret}@hub.testingbot.com/wd/hub", options: options)
      end
    
      after(:all) do
        @driver.quit
      end
    
      it "should have a welcome page" do
        username = 'Test User'
        @driver.get 'http://localhost:8001'
        @driver.find_element(:name, 'name').send_keys username
        @driver.find_element(:css, "input[type='submit']").click
        actual_text = @driver.find_element(:css, "h2").text
        expect(actual_text).to eq("Welcome, #{username}")
      end
    
    end

Was this page helpful? Yes No 

## Looking for More Help?

Have questions or need more information?   
 You can reach us via the following channels:

- [Email us](https://testingbot.com/contact/new)
- [Join our Slack Channel](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
