0

I want to know if there's a way to perform a page.should assertion with a page object element directly, instead of giving the xpath or CSS selector string as a parameter.

i.e.:

Page class:

class FooClass < SitePrism::Page
  element :action_select, '.autocomplete.medium'
end

Step definition:

page.should have_css('.autocomplete.medium')

#Sort of thing desired:

page.should have_css(action_select.get_css)

That .get_css does not exist but it's used to illustrate what's desired.

1 Answer 1

2

The element method creates a has_<element name>? method that can check the existence of the element.

For example, for your page:

page.has_action_select?
#=> returns true if it exists, false if it doesn't

This allows your assertion to be:

page.should have_action_select

For more details, you can see the site prism page.

1
  • Great answer thanks Justin Ko and great info there Nat Ritmeyer! Sep 19, 2014 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.