Simple page objects for Capybara
Ruby
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
gemfiles Added Gemfile for travis ci Oct 12, 2013
lib
spec Update readme with elements selector. Bump version Jul 31, 2014
.gitignore Gem source initial commit Aug 12, 2013
.travis.yml Added Gemfile for travis ci Oct 12, 2013
LICENSE Initial commit Aug 12, 2013
README.md Update readme with elements selector. Bump version Jul 31, 2014
tooth.gemspec Version bump - new feature "elements" added Jul 31, 2014

README.md

tooth

Simple page objects for Capybara

=====

Build Status

How to install

gem install tooth

or with bundler add the following line to your Gemfile:

gem 'tooth'

You can create page objects and page components using simple DSL. These page objects will incapsulate all selectors and remove duplication from you tests:

class NavigationComponent
  extend PageObject # inject page object 'role' for component

  element :logo, '.logo'
end

class HomePage
  extend PageObject

  # simple_divs
  element :headline, 'div#some-id'
  element :some_div_lambda, ->(id){ "div#some-#{id}" }
  element :not_existing, '#not-existing-element'
  elements :all_divs, 'div'

  # components_divs
  within 'div#component1-id' do
    element :inside_div, '.second-lvl'
    element :inside_div_lambda, ->(lvl){".second-#{lvl}"}
  end

  # components_divs
  component :component1, NavigationComponent, 'div#component1-id'
  component :component1_lambda, NavigationComponent, ->(id){ "div#component1-#{id}" }

  # components2_divs
  within '#scope-two' do
    component :component2, NavigationComponent, 'div#component1-id'
  end
end

Then inside tests you can use these objects (methods return Capybara elements):

expect(HomePage.headline.text).to eq 'Headline text'