The Web Automation with Selenium, Ruby & Cucumber Tutorial is a three-part guide that will take you through the process of automating web applications using the Selenium open source testing tool. This guide will show you how to use Selenium with Ruby and Cucumber to write automated tests for web applications. In the first part of the tutorial, we showed you how to install Selenium and write your first test. In the second part of the tutorial, we showed you how to use Ruby and Cucumber to write more sophisticated tests. In this third and final part of the tutorial, we will show you how to use Selenium with Cucumber to automate a web application.
We will be using the www.saucelabs.com web application for this tutorial. This web application has a number of different input fields and buttons that we can interact with using Selenium. We will be writing a series of Cucumber scenarios that exercise different parts of the www.saucelabs.com web application.
In order to follow along with this tutorial, you will need to have Selenium installed on your machine. You can find instructions on how to do this in the first part of the tutorial. You will also need Ruby and Cucumber installed. Again, instructions on how to do this can be found in the first part of the tutorial. Let’s get started!
The first thing we need to do is write a cucumber scenario that exercises the login functionality of www.saucelabs.com . The login scenario should look like this:
Feature: Login Scenario
Scenario: Login Successful
Given I am on the Saucelabs home page
When I enter my username and password into the login form
And I click on the login button
Then I should be taken to my account page
This scenario exercises the happy path for logging into www .saucelabs .com . Let’s see how it works! The first step, Given I am on the Saucelabs home page , navigates our browser to www .saucelabs .com usingSelenium’s get method . Next, we enter our username and password into their respective fields usingSelenium’s sendKeys method . Finally, we click onthe login button usingSelenium’s click method . When these steps are executed, our browser should be redirectedto our account page where we can see our usernameand avatar displayed .