Project

mohawk

0.01
Low commit activity in last 3 years
No release in over a year
Mohawk is a page-object style driver that makes it easy to automate windows applications. It allows you to create a very flexible, clean and natural DSL around whatever windows application that you are trying to automate using the RAutomation gem as the underlying driver.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

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:

  • :user_name - gets the value
  • :user_name= - sets the value
  • :clear_user_name - clears the value
  • :enter_user_name - types the given value (useful for masked text fields)
  • :user_name_view - the raw RAutomation view

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:

  • :ok - clicks the button
  • :ok_value - returns the text value of the button
  • :ok_view - the raw RAutomation view

combo_box

aliases
  • :combobox
  • :dropdown / :drop_down
  • :select_list

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:

  • :city - returns the currently selected item
  • :clear_city - clears the item by either index, value or RegEx
  • :city_selections - returns the currently selected options
  • :city= / :select_city - sets the selected item by index, value or RegEx
  • :city_options - returns the list of available options
  • :city_view - the raw RAutomation view

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