appfolio / ae_page_objects

Page Objects for Capybara
MIT License
28 stars 9 forks source link

Respect options in item_locator when looking up items in collections #189

Closed tlconnor closed 8 years ago

tlconnor commented 8 years ago

Currently any options passed in item_locator for collections are ignored.

For example, given a collection where we only want the visible elements:

collection :children, item_locator: ['li', { visible: true }]

where the markup looks something like this:

<ul>
  <li>First Child</li>
  <li style="display:none">Second Child</li>
  <li>Third Child</li>
</ul>

then children.size will run the query [:xpath, './/li'] to look up children and [:xpath, './/li[2]'] to find the second child. This causes two problems:

  children.size == 3 # should be 2
  children[1].text == 'Second Child' # shoud be 'Third Child'

This PR changes the behavior to pass options through when looking up children. That means now children.size will run the query [:xpath, './/li', { visible: true }] to look up children and [:xpath, './/li[2]', { visible: true }] to find the second child. So now

  1. children.size == 2
  2. children[1].text == 'Third Child'
tlconnor commented 8 years ago

@rmacklin @bboe thanks for your feedback on this. I've made the required changes and this is ready for re-review.