Get select value of dropdown for capybara testing

前端 未结 6 2025
说谎
说谎 2020-12-24 10:33

I have to write tests for a web site. I am trying to get the selected value of a dropdown box. So far i can get the contents of the dropdown by doing

find_f         


        
6条回答
  •  执笔经年
    2020-12-24 11:02

    There's a have_select matcher if you use Capybara with Rspec:

    expect(page).to have_select('my-select', selected: 'Option 2')
    

提交回复
热议问题