How to check a checkbox in capybara?

前端 未结 13 1924
灰色年华
灰色年华 2020-11-30 23:34

I\'m using Rspec and Capybara.

How can I write a step to check a checkbox? I\'ve tried check by value but it can\'t find my checkbox<

13条回答
  •  一向
    一向 (楼主)
    2020-11-30 23:53

    I know this is an older question, but I have been working through this myself, and having tried all of the above, this is what finally worked for me:

    find("input[type='checkbox'][value='#{cityID.id}']").set(true)
    

    Hope this is helpful to someone. I am using Capybara 2.4.4.

提交回复
热议问题