使用 Watij 测试 jQuery 更改事件

发布于 2024-08-23 06:38:34 字数 614 浏览 2 评论 0原文

我有一个选择列表,其中更改事件已使用 jQuery 绑定到元素。就像这样:

$("#someId").change(function() {..});

当有人在选择列表中选择一个新选项时,用户界面的另一部分将相应地发生变化。现在,当我使用鼠标并单击内容时,效果很好,但是,当使用 Watij 时,效果很好为了编写我的测试,我需要触发 jQuery 更改事件,但它没有执行。

Watij 测试将正确选择所需的选择选项,但实际事件不会被触发。我尝试调用 fireevent("change");fireevent("onchange"); 无济于事。我还尝试过 ie.sendKeys("{ENTER}");ie.sendKeys("{TAB}"); 这似乎也不起作用。

有什么想法吗?

I have a select list where a change event has been bound to the element using jQuery. Something like this:

$("#someId").change(function() {..});

When someone chooses a new option in the select list, another part of the UI will change accordingly. Now this works fine when I use the mouse and click things, however, when using Watij to write my tests I need the jQuery change event to fire which it isn't doing.

The Watij test will correctly choose the select option required but the actual event does not get triggered. I have tried calling fireevent("change"); and fireevent("onchange"); to no avail. I have also tried ie.sendKeys("{ENTER}"); and ie.sendKeys("{TAB}"); which also does not seem to do the trick.

Any ideas?

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

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

发布评论

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

评论(3

叹梦 2024-08-30 06:38:34

到目前为止我找到的唯一解决方案是回滚正在使用的 jQuery 版本。我目前正在使用版本 1.4.1(关于选择框上更改事件的可测试性的违规版本),返回到版本 1.2.6 后问题就消失了。

The only solution I've found so far is to roll back the version of jQuery in use. I'm currently using version 1.4.1 (the offending version in regards to the testability of the change event on select boxes) and after going back to version 1.2.6 the problem goes away.

挽手叙旧 2024-08-30 06:38:34

使用 $('#someId').trigger('change'); 手动触发事件。

请参阅 trigger() 的文档。

Use $('#someId').trigger('change'); to fire the event manually.

See the documentation for trigger().

捶死心动 2024-08-30 06:38:34

当使用脚本更改组合/列表值时,不应触发 onchange。我不知道 Watij 是如何做到这一点的,但这是一个案例。

第二件事是 Watij 正在与 IE 合作(只要维基百科是正确的)并且 IE 正在放置一个系统控件来代替您的列表或组合,它也可能会破坏某些东西。尝试升级到 IE8,它对表单组件的实现有一点点更好(例如,选择在 10 年后终于支持选项中的“禁用”属性)

您可能还对普通应用程序 GUI 测试应用程序感兴趣,并在浏览器上使用它们网络应用程序。录制宏并检查屏幕截图。

When the combo/list value is changed with script the onchange is not supposed to fire. I don't know how Watij is doing that, but this is one case.

Second thing is that Watij is working with IE (as long as wikipedia is rght) and IE is putting a system control in place of Your list or combo and it might break something too. Try upgrading to IE8 which has a tiny bit better realisation of form components (eg. select finally supports "disabled" attribute in options after 10 years)

You might also be interested in a normal application GUI testing apps and use them on a browser with the webapp. Record a macro and check screenshots.

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