capybara

Capybara testing value of hidden field


I have a form with a hidden field that contains the current date.

I'm trying to figure out how to write a capybara finder to:

  1. Check that the field is there
  2. Check the value of the field

Is this possible with Capybara?


Solution

  • its simple you can do it by using find_by_css or by using xpath as follow

    page.find_by_css('#foo .bar a') #foo is the id the foo has .bar class
    page.find('/table/tbody/tr[3]') #path of the element we want to find