Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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></option>

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

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

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

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

</select>

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)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...