rubyobjectpageobjectspage-object-gem

Clicking a link that's nested inside a div using page-object gem


I have a page that has a link More restaurants. I'm not sure how to access it using page-object gem by Cheezy.

When I click the link, it opens up a modal showing more restaurants than the ten in a list that it shows by default.

<div class="singleselect-radio-footer">
    <a href="" ng-click="toggleModal('singleselecRadioMoreOptionsModal.html')" r_test="singleselect-link-SelectRestaurant-more" ng-show="alwaysShowMoreLink || items.length > limit" class="ng-binding">More Restaurants</a>
</div>

I tried to use link

link(:more_restaurants, text: 'More Restaurants')

more_restaurants.click

and

div(:more_restaurants, class: 'singleselect-radio-footer')

def try_to_click
  sleep(2)
  self.more_restaurants_element.click
end

I'm wondering what the easiest way is to access such elements without an id.


Solution

  • To access the underlying methods for that link using Page Object gem you would need to add '_element' as a suffix to the name.

    link(:more_restaurants, text: 'More Restaurants')
    more_restaurants_element