capybara finds button but clicking it does nothing

£可爱£侵袭症+ 提交于 2019-12-23 15:11:51

问题


UPDATE: I removed most javascript dependencies and it worked. Don't know what library or code is the evil part, I needed none of it.


simple form, two input fields and a button

fill_in 'cellNumber', :with => '13245678'
fill_in 'password', :with => 'mypass'
click_button('OK')

It finds the button, but nothing happens.

Important!, if I click the myself, everything works as expected.

   <button type="submit" id="loginid">OK</button>
</form>

Using ruby-debug, I find that find_button("OK").click returns "". If not found would raise error. If I click manually inside the firefox window, halting the capybara test with sleep or in debug, I see (test window in focus) a blue frame has appeared around the button , as it's been selected somehow.

Anyway, I'm close to checking in to a mental facility right now... Any suggestions?


回答1:


Javascript may interfere. The page had some unnecessary dependencies to Squeezebox, Mootools-1.2.5 and Function.cbb.js, so I just removed them and refactored to use more css functionality (like hover) and specialized js. I'm not impressed with this. Nonetheless, I hope this answer would help others.

update: Seems like Mootools is incompatible with Selenium. Without including any other JS library/code than the mootools core library, it breaks. I've tried both 1.2.5-core and 1.3.2-full-compact.



来源:https://stackoverflow.com/questions/6996141/capybara-finds-button-but-clicking-it-does-nothing

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