如何使用水豚来检查选择框是否列出了某些值作为选项?它必须与selenium兼容…
这是我拥有的HTML:
<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>
这是我想做的:
Then the "cars" field should contain the option "audi"
尝试使用capybara rspec匹配器have_select(locator,options = {})代替:
#Find a select box by (label) name or id and assert the given text is selected Then /^"([^"]*)" should be selected for "([^"]*)"$/ do |selected_text, dropdown| expect(page).to have_select(dropdown, :selected => selected_text) end #Find a select box by (label) name or id and assert the expected option is present Then /^"([^"]*)" should contain "([^"]*)"$/ do |dropdown, text| expect(page).to have_select(dropdown, :options => [text]) end