LitePage
A gem providing a quick, clean, and concise means of implementing the Page Object Model pattern and defining a semantic DSL for automated acceptance tests using watir-webdriver.
Installation
Add this line to your application's Gemfile:
gem 'lite_page'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lite_page
Usage
If you are using cucumber, include the page initialization helper methods in the cucumber World instance.
World(LitePage::PageInitializers)
Include LightPage
in your page objects, define a page_url
(if you want to be able to use the PageInitializers
), and define elements on the page.
Page elements are defined by calling a method corresponding to the appropriate element type and passing it the name by which you wish to access the element and the selectors used to locate it.
class LoginPage
include LitePage
page_url('http://www.example.com/login')
text_field(:username, :label => 'Username')
text_field(:password, :label => 'Password')
(:log_in_button, :text => 'Log In')
def log_in(username, password)
self.username.set(username)
self.password.set(password)
self..click
end
end
Visit and interact with your page objects.
visit(LoginPage).login('afinch', 'pa55w0rd')
Contributing
- Fork it ( http://github.com/saclark/lite_page/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request