-1

Using cucumber site-prism.I'm navigating to a page and wants to check all elements present on that page.I used this code but not able to print this generic message.

"@sign_in" is the object of the class where i have defined all sign in elements "table" contains all the elements name

table.hashes.each do |link|
 expect(@sign_in.send(link[:Login_elements])).to be_truthy ,  "link[:Login_elements]) is not present"
end
Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
  • What output do you get? What output do you want to get? – Thomas Walpole Aug 05 '16 at 07:13
  • For failing scenario i get "Unable to find css", the output i want is the "link[:Login_elements]) is not present ". Which is executed only when expectation fails. – Harsh Agarwal Aug 05 '16 at 08:17
  • Please see the [minimum, verifiable, and complete](http://stackoverflow.com/help/mcve) guide. You can't expect people to solve your problem if you don't show the steps you've taken thus far, including all relevant code. – max pleaner Aug 05 '16 at 08:20
  • Looks like you're getting an `Capybara::ElementNotFound` exception from `@sign_in.send(link[:Login_elements])`? – moertel Aug 05 '16 at 14:03

1 Answers1

0

The methods you are calling via send return the element or raise an exception if the element isn't on the page which isn't going to work with be_truthy. Instead you need to use the boolean has_xxx? methods site-prism provides (or you could use the raise_error matcher with a block of code)

table.hashes.each do |link|
  expect(@sign_in.send("has_#{link[:Login_elements]}?")).to be_truthy , "link[:Login_elements]) is not present"
end
Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78