Tinkering with Gauge, and Selenium-Ruby for first time.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
env/default
specs
step_implementations
Gemfile
Gemfile.lock
LICENSE
README.md
manifest.json

README.md

gauge-selenium-ruby-first-draft

T.J. Maher's first attempt using Gauge.org + Selenium-Ruby, ripping off code from Gauge's example project, ruby-selenium so he can attempt to understand this BDD framework he is encountering for the first time.

T.J. Maher knows how to write Base Page Objects, Page Objects, making tests data driven, and how to add good exception handling and logging in Java, but not in Ruby. Do you know that? Maybe you can help answer a few questions.

This project focuses on understanding the Gauge framework, not selenium-ruby. Both the Ruby code and the Selenium formatting are left as minimalist and unstructured as possible, hacked together quickly to get it up and running.

Running this example

The tests are run on Headless Chrome by default.

Prerequisites

This example requires the following softwares to run.

  • ruby-2.3.1 or above
  • Gauge
  • Gauge Ruby plugin
    • can be installed using gauge install ruby
  • Chrome

The System Under Test (SUT)

Run specs

Go into the gauge-selenium-ruby-first-draft and make sure you have all the dependencies. Run: bundle

You can execute specs as bundle exec gauge specs Gauge specs are run with Maven.

Chrome is the default browser for specs execution. Make sure Chrome is installed in your machine and chromedriver is in PATH.

How is this project scaffolded?

What is wonderful about Gauge is that I did not have to use Yeoman.io or any other tool to scaffold this project, i.e. figure out the folder structure and code just to get things up and running. I created a new directory on my local machine, entered the directory, and entered:

gauge init ruby

Want to see what code that command produced? See the gauge_0.9.7_default_code that I stored on GitHub.

All I had to do was take the Ruby code that Gauge created in ruby-selenium, and hack on it inexpertly until it could run the The-Internet Login.

I'm only week two into working with Ruby.

Questions: Are you an expert on Gauge?

How do you work with selenium-ruby?

I was planning on working towards what Dave Haeffner has in ElementalSelenium.com creating a library of:

I am brand-new to Gauge and using Selenium-Ruby. So far I only have used Selenium-Java.

It looks like Gauge strongly advocates against page objects calling them an Anti-Pattern. Er... Um... burying a page's locators in code, as they do in the blog makes me worried. Looking for other solutions.

Contents

env/default:

  • default properties: Points to where the reports and logs are, chooses Chrome to be the default browser, and chooses whether or not you should overwrite reports, capture screenshots on failure, enable multithreading. You can also choose when you want the objects to be cleatred... after execution of suite, spec, or scenario.
  • user properties: Points to the APP_URL, and chooses if you want the tests to be headless or not.

specs

  • UserAction.spec: Heavily ripped off of the Gauge sample project, ruby-selenium, this is the "executable specification file. This file follows markdown syntax. Every heading in this file denotes a scenario. Every bulleted point denotes a step". Contains "Login as username and ", "Check if the user is logged in" and "Log out". Also contains a data table for username and passwords.
  • concepts/Authentication.cpt: Specs can refer to these concepts, "Check if the user is logged in" and "Log out", breaking them down.

step_implementations

  • authentication.rb: Contains the selenium-ruby code that acts out the steps "Give an option to Log Out", 'Give an option to Log In' and a logout method.
  • user_login: Contains the step "Login as username and ", which uses selenium-ruby to send text to the username and password textbox, and presses the Login button.

step_implementation_utils

  • driver.rb: Contains the setup and teardown methods, creating the driver and quitting the driver. Also sets up the driver with:
options = Selenium::WebDriver::Chrome::Options.new
@@driver = Selenium::WebDriver.for :chrome, options: options
options.add_argument('--headless')
options.add_argument('--disable-gpu')
  • find_message: Any messages that you need to check for? There is this method that Gauge's ruby-selenium has, "Show a message ".

  • screengrabber.rb: Provides a wrapper for driver.save_screenshot('/tmp/screenshot.png')

  • site_launcher: Contains the step "Navigate to the login page", which then does:

  assert_equal 'The Internet', driver.title

Gemfile: The dependencies for the project.