Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

How do I use Capybara to check that a select box has certain values listed as options? It has to be compatible with Selenium...

This is the HTML that I have:

<select id="cars"> 


  <option value="volvo">Volvo</option>

  <option value="saab">Saab</option>

  <option value="mercedes">Mercedes</option>

  <option value="audi">Audi</option>


This is what I want to do:

Then the "cars" field should contain the option "audi"

1 Answer

0 votes
by (27.5k points)

This code should do the magic:

page.all('select#cars option').map(&:value).should == %w(volvo saab mercedes audi)

Browse Categories