Awesome Browser Automation — Chapter 02

In the previous post, we set up our Cucumber Ruby project. In this post, we prepare configuration variables and env.rb file to run future scenarios.

In this pull request, you can explore changed files for Chapter 02.


The entry point for settings variables that are no secret. We have SITE, HEADLESS, and BROWSER that are described in


This clumsy path is a development decision in the Cucumber gem library. This is the central entry point for the Cucumber project. Here you require all Ruby gems that you need to use. After that, we read application variables and set where webdrivers gem will automatically keep up to date webdriver files.


method maximizes the browser to the size of the screen resolution where the browser is run. We do that in order to have the same situation as when we create scripts, in full window resolution. execute_script executes JavaScript in the browser. This is the Watir method.

Before and After the scenario is called before/after scenario steps run. Something like setup, teardown in Junit. Before the scenario, we instantiate selected browsers in maximal screen resolution and in selected headless mode. If the scenario fails, we embed a screenshot in the HTML test report. This is also a Watir feature. In the end, we close the browser.

Run cucumber. Nothing happens because we do not have a scenario with steps. We are ready for chapter 03!

Originally published at on December 11, 2019.

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store