AutomationObject Ruby Gem for UI Automation Published


AutomationObject Ruby gem is a YAML configuration based dynamic DSL framework for UI automation using Selenium or Appium drivers.

Gem Purpose:

The purpose of this gem was to provide a layer in between the drivers I commonly used and my Cucumber testing suite. Using YAML configurations to define and map the UI, this gem enables the creation of a dynamic DSL framework reflecting the configuration that allows automation to occur through the provided DSL API.

Reason for Creating:

Working as a QA developer in Test, I was having a hard time figuring out how I could scale up our testing codebase. I had an idea which included using configurations to define UI automation behavior and combine that with Ruby’s super sweet meta programming (reflection) abilities to create a dynamic DSL framework that controls the UI automation. Using the DSL framework which represented the UI I wanted to automate, I could issue commands to the framework and keep the complexities of UI automation hidden from the rest of the codebase.

The hope was that the codebase growth would be limited to the YAML configurations and cucumber features, and nowhere else. With the proper organization of the YAML configuration files, I could continue to grow those configurations and have legacy versions stored too. Using stateless step definitions, I wouldn’t have continual growth in that part of the codebase. Then finally, cucumber features that would test specific sites that can write my essay online or apps using specific YAML configurations would be the only other part to grow.

Example YAML Configuration File:

qiita.rb
base_url: 'http://www.spartzinc.com'
default_screen: 'home_screen'
screens:
  home_screen:
    elements:
      team_link:
        css: '#path div.to #element'
          click:
            after:
              change_screen: 'team_screen'
  team_screen:
    before_load:
      wait_for_elements:
        - element_name: 'title'
          exists?: true
          visible?: true
          text: 'Meet Our Team'
    elements:
      title:
        xpath: '//path/to/element'

Example Ruby File:

qiita.rb
require 'automation_object'
require 'selenium-webdriver'

#New Selenium Driver
driver = Selenium::WebDriver.for :chrome

#Will load split up YAML files and return them merged into one Hash object
blue_prints = AutomationObject::BluePrint.new('/file/path/containing/yaml/files')

#Create the DSL framework
automation_object = AutomationObject::Framework.new(driver, blue_prints)

#Now lets automate, default screen is home_screen
automation_object.home_screen.team_link.click

#Framework has already executed the waiting hooks in the config above
#Now lets print out the team screen title
puts automation_object.team_screen.title.text

Fair Warning:

This is the initial release of this gem, kind of a proof of concept. There is a lot of coupling and very long methods that make this gem less appealing, but it is stable. Although we do use this at our company for all of our UI testing and we have a very stable and scalable testing codebase.

Future Plans:

I plan on creating a new class/object structure, unit testing, internal documentation to support further growth of this gem by the end of Q1 2015. Also considering adding Cucumber step definitions for your use that will implement the AutomationObject framework so that testing will be plug and play, only needing features and configurations from you.

Finally:

I am very grateful that my managers at Spartz allowed me to pursue this idea, even though I had no idea how this would be implemented. The idea ended up working out for us and I hope you may get some use out of it too.

Installation Instructions:
https://github.com/spartzinc/automation_object#installation
Source Code:
https://github.com/spartzinc/automation_object
Examples:
https://github.com/spartzinc/automation_object/blob/master/docs/README.md#examples
RubyGems:
https://rubygems.org/gems/automation_object