Home

Awesome

Mohawk

Build Status Coverage Status

A gem to assist in building page-object like structures for testing Windows applications.

Installation

Runtime Environment

In order for mohawk to work, you need to have the .NET 4.0 Framework as well as the C++ Runtime Redistributable.

Ruby Environment

Add this line to your application's Gemfile:

gem 'mohawk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mohawk

Example

Defining a screen

require 'mohawk'

class LoginScreen
  include Mohawk
  window(:title => /Login/)

  text(:username, :id => "UserNameField")
  text(:password, :id => "PasswordField")
  
  button(:login, :value => "Login")
end

Using the Page-Object

World(Mohawk::Navigation)

on(LoginScreen) do |screen|
  screen.username = "levi"
  screen.password = "secret"
  screen.login
end

Accessors

Window

window

The window accessor defines how to locate the top-level window that you would like to use for your screen. Valid locators are dictated by the RAutomation::Window class.

parent

There are times where you need to define the root parent window for your screen, but it happens to be within a child window of a top-level window. The parent accessor allows you to specify further within window, and that will be used as the root of all other searches.

Controls

Control accessors are used to define various controls within your page object. Valid locators are dictated by the RAutomation::Control class.

text

The text accessor is used to define an edit text control within your screen. Given text(:user_name, id: 'txtUserName'), you will get the following methods:

button

The button accessor is used to define a button control within your screen. Given button(:ok, value: 'OK'), you will get the following methods:

combo_box

aliases

The combo_box accessor is used to define a control that implements the SelectList pattern, such as a ComboBox, ListBox, etc. Given combo_box(:city, id: 'cbCities'), you will get the following methods:

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request