Capybara choose(“radio button”) not working

邮差的信 提交于 2019-12-05 12:05:30

I've had this issue a number of times. If you choose form elements based on their ID in the dom it's far more reliable:

before do 
  choose 'request_item_headlamp'
  click_button submit
end

I can't tell without looking what ID rails would come up with for the other radio button. Just right click it in chrome, inspect element, and cut and paste the element ID into your test.

I suspect sometimes when choose doesn't reliably check a radio button, it may be because an animation is in progress.

If you suspect this is causing your choose calls to be unreliable, try disabling animations, say by setting their execution time to 0 seconds in your test environment. Alternatively build in a wait period in your test for the animation to finish.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!