Watir 不触发 Jquery 事件处理程序

发布于 2024-07-25 15:00:30 字数 166 浏览 1 评论 0原文

我正在测试 JQuery Web 应用程序。 我有一个 JQuery 弹出窗口,我根本无法在 Watir 中触发提交按钮。 应用程序使用相同的模式。

我已经验证了该按钮是否存在,并尝试了单击、fireEvent(您将其命名),但没有方法可以调用。

有人解决这个问题了吗?

I am testing a JQuery Web application. I have a JQuery popup that I simply cannot get the submit button to fire in Watir. The same pattern is used thought the application.

I have verified the button exists and have tried click, fireEvent you name it and am out of methods to call.

Has anyone solved this?

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

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

发布评论

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

评论(3

夜灵血窟げ 2024-08-01 15:00:30

你想要哪个?
A.控制光标点击“提交”

B. 模拟点击“提交”

A:需要使用Autoit 并控制光标并点击,但仅适用于windows 操作系统。 B:执行点击“提交”时的javascript。

如果是B情况,我一直用的有两种方法。
1.执行URL栏中的代码。
例如) @ie.link(:URL, 'javascript:<-CODE->;').click

制作类似的模块并通过包含在测试用例中来使用它。
例如)@ie.excute_script(<-CODE->)

module Watir
  class IE
   def execute_script(scriptCode)
     WIN32OLE.codepage = WIN32OLE::CP_UTF8
     window.execScript(scriptCode)
   end
   def window
     WIN32OLE.codepage = WIN32OLE::CP_UTF8
     ie.Document.parentWindow
   end
  end

也许...
我希望它有帮助。
抱歉我的英语不好。
tknv/

Which do you want ?
A. Control cursor and click "submit"
or
B. Simula te click "submit"

A:need to use Autoit and control cursor and click ,but only for windows OS. B:execute the javascript that when clicking "submit".

If B case,there is two ways I used always.
1.execute that code in URL-bar.
ex.) @ie.link(:URL, 'javascript:<-CODE->;').click
or
Make like that module and use it by include in test case.
ex.) @ie.excute_script(<-CODE->)

module Watir
  class IE
   def execute_script(scriptCode)
     WIN32OLE.codepage = WIN32OLE::CP_UTF8
     window.execScript(scriptCode)
   end
   def window
     WIN32OLE.codepage = WIN32OLE::CP_UTF8
     ie.Document.parentWindow
   end
  end

Maybe...
I hope it help.
Sorry my poor english.
tknv/

原来分手还会想你 2024-08-01 15:00:30

在我的例子中,解决方案是使用索引值 1。JQuery 创建表单的副本,所有弹出项的索引为 1。0 索引控件位于原始表单上。

In my case the solution was to use and index value of 1. JQuery creates a copy of the form and all the popup items have an index of 1. The 0 index controls are on the original form.

放血 2024-08-01 15:00:30

我刚刚遇到了同样的问题。 jQuery 演示的 Ajax 上传 是一个示例页面。 我想使用页面左侧的 Upload 按钮上传文件。

当我手动点击上传按钮时,弹出文件上传< /a> 出现。

当我点击 Watir 按钮时,没有任何反应。

加里(接受的答案)帮助我找到了解决方案:

browser.file_field(:index, 1).set "/path/to/file"

I just had the same problem. Ajax upload for jQuery demo is an example page. I want to upload a file using Upload button on the left hand side of the page.

When I click Upload button by hand, file upload pop up appears.

When I click the button with Watir, nothing happens.

Gary (accepted answer) helped me to find a solution:

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