【发布时间】:2015-01-09 19:49:27
【问题描述】:
我正在编写一个 watir-webdriver 测试脚本来将文件上传到应用程序。我的应用程序使用剑道小部件,例如以下 http://demos.telerik.com/kendo-ui/upload/index
我可以在调试代码时与 windows 对话框进行交互,但是当我一起执行它时,它会超时,因为 windows 对话框模式似乎永远不会获得焦点。代码如下:
require 'win32ole'
sleep 1
wsh = WIN32OLE.new('Wscript.Shell')
## open the windows dialog modal.
@browser.div(:class => "k-button k-upload-button").click
### Code times out after the above click, it never executes the below steps as app looses focus, don't know how I can switch the focus to windows modal and execute below code.
@browser.windows.last.use do
sleep 2
wsh.AppActivate("File Upload")
sleep 2
wsh.SendKeys "{TAB}"
sleep 1
wsh.SendKeys("file path")
sleep 1
wsh.SendKeys "~"
end
错误:
Net::ReadTimeout (Net::ReadTimeout)
【问题讨论】:
-
没有
<input type="file">标签?如果有,#file_field可能会成功。 -
是的,它不存在,我能够通过多线程找到解决方案。
标签: watir watir-webdriver