水豚发现按钮,但单击它没有任何作用 [英] capybara finds button but clicking it does nothing

查看:100
本文介绍了水豚发现按钮,但单击它没有任何作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我删除了大多数javascript依赖项,并且它起作用了。不知道什么库或代码是最有害的部分,我什么都不需要。

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>

使用ruby-debug,我发现find_button( OK)。click返回。如果找不到,则会引发错误。
如果我在firefox窗口中手动单击,通过睡眠或调试暂停水豚测试,则会发现(围绕测试窗口的焦点)按钮周围出现了一个蓝色框,因为它是通过某种方式选择的。

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?

推荐答案

JavaScript可能会干扰。该页面对Squeezebox,Mootools-1.2.5和Function.cbb.js有一些不必要的依赖,因此我只是删除了它们,并重构为使用更多的CSS功能(如悬停)和专用js。我对此没有印象。尽管如此,我希望这个答案对其他人有帮助。

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.

更新:似乎 Mootools 不兼容硒。除了不包含mootools核心库以外的任何其他JS库/代码,它都会中断。我曾经尝试过1.2.5核和1.3.2核对。

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.

这篇关于水豚发现按钮,但单击它没有任何作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆