Home > Blockchain >  (Capybara, Ruby) How do i check the dropdown has more than 1 value (7 values in this case)?
(Capybara, Ruby) How do i check the dropdown has more than 1 value (7 values in this case)?

Time:09-22

(New to testautomation) Hopefully someone can help me out. I need to be able to check the dropdown has a specific amount of values (in my case 7 different values) which change every month or so. So I can't hardcode the values that are within this dropdown.

How do I get it to check the dropdown has 7 values, independent of what the actual value is?

For example:

<option value="">""</option>
<option value="123456">XZY</option>
<option value="123457">ZYX</option>
<option value="123458">ABC</option>
<option value="123459">CBA</option>
<option value="123460">BAC</option>
<option value="123461">DEF</option>``` 

And next month it would be: 
<option value="">"-"</option>
<option value="123457">ZYX</option>
<option value="123458">ABC</option>
<option value="123459">CBA</option>
<option value="123460">BAC</option>
<option value="123461">DEF</option>
<option value="123462">FED</option>

CodePudding user response:

You can try this.

within("select.form-select") do
   page.all('option', count: 7)
end
  • Related