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.
我正在测试一个JQuery Web应用程序。我有一个JQuery弹出窗口,我根本无法在Watir中触发提交按钮。考虑应用程序使用相同的模式。
I have verified the button exists and have tried click, fireEvent you name it and am out of methods to call.
我已经验证了该按钮的存在并尝试了点击,fireEvent您将其命名并且没有方法可以调用。
Has anyone solved this?
有人解决了这个吗?
3 个解决方案
#1
Which do you want ?
A. Control cursor and click "submit"
or
B. Simula te click "submit"
你要哪个 ? A.控制光标并单击“提交”或B.模拟单击“提交”
A:need to use Autoit and control cursor and click ,but only for windows OS. B:execute the javascript that when clicking "submit".
答:需要使用Autoit和控制光标并单击,但仅适用于Windows操作系统。 B:点击“提交”时执行javascript。
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->)
如果是B的情况,总有两种方法可以使用。 1.在URL-bar中执行该代码。 ex。)@ ie.link(:URL,'javascript:< - CODE - >;')。点击或制作该模块并通过包含在测试用例中使用它。 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/
也许......我希望它有所帮助。抱歉,我的英语很差。 tknv /
#2
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.
在我的情况下,解决方案是使用和索引值1.JQuery创建窗体的副本,所有弹出项目的索引为1. 0索引控件在原始窗体上。
#3
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.
我刚遇到同样的问题。 jQuery demo的Ajax上传是一个示例页面。我想使用页面左侧的“上传”按钮上传文件。
When I click Upload
button by hand, file upload pop up appears.
当我手动点击上传按钮时,会出现文件上传弹出窗口。
When I click the button with Watir, nothing happens.
当我用Watir点击按钮时,没有任何反应。
Gary (accepted answer) helped me to find a solution:
加里(接受了答案)帮我找到了解决方案:
browser.file_field(:index, 1).set "/path/to/file"
#1
Which do you want ?
A. Control cursor and click "submit"
or
B. Simula te click "submit"
你要哪个 ? A.控制光标并单击“提交”或B.模拟单击“提交”
A:need to use Autoit and control cursor and click ,but only for windows OS. B:execute the javascript that when clicking "submit".
答:需要使用Autoit和控制光标并单击,但仅适用于Windows操作系统。 B:点击“提交”时执行javascript。
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->)
如果是B的情况,总有两种方法可以使用。 1.在URL-bar中执行该代码。 ex。)@ ie.link(:URL,'javascript:< - CODE - >;')。点击或制作该模块并通过包含在测试用例中使用它。 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/
也许......我希望它有所帮助。抱歉,我的英语很差。 tknv /
#2
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.
在我的情况下,解决方案是使用和索引值1.JQuery创建窗体的副本,所有弹出项目的索引为1. 0索引控件在原始窗体上。
#3
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.
我刚遇到同样的问题。 jQuery demo的Ajax上传是一个示例页面。我想使用页面左侧的“上传”按钮上传文件。
When I click Upload
button by hand, file upload pop up appears.
当我手动点击上传按钮时,会出现文件上传弹出窗口。
When I click the button with Watir, nothing happens.
当我用Watir点击按钮时,没有任何反应。
Gary (accepted answer) helped me to find a solution:
加里(接受了答案)帮我找到了解决方案:
browser.file_field(:index, 1).set "/path/to/file"