Simple object mapper for page objects with capybara
Add this line to your application's Gemfile:
gem 'capybara-pagemap'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capybara-pagemap
Inherit from Capybara::Pagemap::Base
and define the input fields as the following example
class LoginPage
include Capybara::Pagemap
define_input :email, '//*[@id="user_email"]'
define_input :password, '//*[@id="user_password"]'
define_button :log_in, '//*[@id="log_in"]'
end
Once you have define your input you will have access to the getters setters
login_page = LoginPage.new
login_page.email = "[email protected]"
login_page.email
# => "[email protected]"
login_page.email_input
# => Capybara::Node
login_page.log_in_button.click if login_page.valid?
Bug reports and pull requests are welcome on GitHub at https://github.com/3zcurdia/capybara-pagemap.