更改 jquery 事件,当使用水豚运行黄瓜时不会触发它

发布于 2024-10-22 03:25:08 字数 228 浏览 1 评论 0原文

我正在用黄瓜和水豚在浏览器中测试一些jquery代码,当更改事件发生时,在文本字段中,它会调用某个函数,当我手动执行此操作时,一切正常,但是当运行黄瓜时,我用以下内容填充文本字段一个新值,但该函数未执行。

同时,还有另一个文本字段与 keyup jquery 事件链接,该事件触发另一个函数,并在浏览器或运行 cucumber 中手动工作,

因此这可能是运行 cucumber 时未触发更改事件回调函数的原因?

I was testing some jquery code in my browser with cucumber and capybara, and in a text field when the change event happen, it calls a certain function, when I manually do this action everything works, but when running cucumber i fill the text field with a new value but the function is not executed.

Meanwhile, there is another text field linked with a keyup jquery event that triggers another function and that works manually in the browser or running cucumber

so which could be the reason for the change event callback function isn't triggered when running cucumber?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风吹短裙飘 2024-10-29 03:25:08

我遇到了同样的错误,但仍然没有找到解决方案。
但是这个家伙(http://pullmonkey.com/2011/03/03/capybara-does-not-trigger-js-change-event-with-celertiy-driver/)模拟了一个更改事件并且似乎有效。

I'm having the same error and still not found the solution.
But this guy (http://pullmonkey.com/2011/03/03/capybara-does-not-trigger-js-change-event-with-celertiy-driver/) simulate a change event and seems to work.

猥琐帝 2024-10-29 03:25:08

我发现的一种简单的解决方法是填充/与另一个输入交互,这样被测试的输入就会失去焦点,浏览器将触发更改事件。有时这是重新排列填充输入顺序的问题,有时这是一个额外的冗余步骤。

One easy workaround I've found is to fill/interact with another input so the one being tested loses focus and browser will trigger change event. Sometimes it's a matter of rearranging sequence of populating inputs, sometimes it's an extra redundant step.

风流物 2024-10-29 03:25:08

我也遇到了这个问题...水豚会填写“12345”,然后我会检查数据库中的密码,它只会是 1234 或 123。

我的解决方法基本上是在我的全局步骤中创建一个辅助方法,该方法采取一个“输入”参数。

所以它的工作原理是这样的:

find('css').set(value)

find('css').set("\n") if enter.present?

本质上,通过这样做,它“确认”输入,就像你作为用户所做的那样。我认为它比单击其他输入或切换页面上的内容以使其捕获输入中的内容更干净,因为它是相对于完全相同的输入的。

I had this problem as well... Capybara would fill out "12345" and then I would check the password in the database and it would only be 1234 or 123.

My workaround was basically to create a helper method in my global steps that took an "enter" argument.

so it works something like this:

find('css').set(value)

find('css').set("\n") if enter.present?

Essentially, by doing this it "confirms" the input, kind of how you would do as a user. I think it's cleaner than clicking other inputs or toggling things on the page to make it capture what's in your input, since it's relative to the exact same input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文