No commit activity in last 3 years
No release in over 3 years
Simple page objects for Capybara. All tooth-generated methods return Capybara Elements so that you can use these familiar objects for your needs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

>= 0

Runtime

>= 2.0.0
 Project Readme

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'