watir测试file_field.set方法问题

Thinkingking 2008-04-12 01:18:46
ie.file_field(:xpath, "//input[@name='file1']/").set($htmlRoot + "fileupload.html")
只能弹出选择对话框,等待用户选择文件。现在想实现自动选择文件的功能,不知道目前有没有谁知道可行的解决方法
请高手指点。
附带测试脚本一份(watir提供的例子)

# feature tests for TextArea Fields
# revision: $Revision: 963 $

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'unittests/setup'

class TC_FileField_XPath < Test::Unit::TestCase
include Watir

def goto_page
$ie.goto($htmlRoot + "fileupload.html")
end

def test_file_field_Exists
goto_page
#test for existance of 4 file area
assert($ie.file_field(:xpath, "//input[@name='file1']/").exists?)
assert($ie.file_field(:xpath, "//input[@id='file2']/").exists?)
#test for missing
assert(!$ie.file_field(:xpath, "//input[@name='missing']/").exists?)
assert(!$ie.file_field(:xpath, "//input[@name='totallybogus']/").exists?)
#pop one open and put something in it.
$ie.file_field(:xpath, "//input[@name='file1']/").set($htmlRoot + "fileupload.html")
#click the upload button
$ie.button(:xpath, "//input[@name='upload']/").click

assert($ie.text.include?("PASS"))
end

def test_iterator
goto_page
assert_equal(6, $ie.file_fields.length)
end

end
...全文
356 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tongki 2008-04-15
  • 打赏
  • 举报
回复
UP!
Thinkingking 2008-04-15
  • 打赏
  • 举报
回复
加分~~~~~
Thinkingking 2008-04-15
  • 打赏
  • 举报
回复
$ie.file_field(:xpath, "//input[@name='file1']/").set($htmlRoot + "fileupload.html")
进程中断,等待“选择文件”子进程返回,但是怎样获得这个子进程id,
小弟刚学习watir和ruby,等待高手帮忙

csdn上这么多高手,继续等待高手解决,感激万分
kelph 2008-04-15
  • 打赏
  • 举报
回复
自动选择文件是什么意思
vanta 2008-04-15
  • 打赏
  • 举报
回复
很想帮你,可是我也无能为力啊!!
楼主加油!

2,764

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧