How to check a checkbox in capybara?

前端 未结 13 1955
灰色年华
灰色年华 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:48

    I found the following worked for me:

    # Check
    find(:css, "#cityID[value='62']").set(true)
    
    # Uncheck
    find(:css, "#cityID[value='62']").set(false)
    

提交回复
热议问题