
我有以下HTML
<body><form method="post" action="upload" enctype="multipart/form-data">test file to upload: <input type="file" name="file" size="60" ID="test"/><input type="submit" value="Upload" name="upload" ID="upload" /></form></body>
我正在尝试单击ID为test的输入,并使用watir-webdriver设置我希望上传的本地文件的路径.
我可以使用以下单击按钮以显示选择窗口
@browser.goto 'http://www.test.com'@browser.button(:ID => 'test').click
但是,我试图使用以下(从研究,这似乎是正确的方法.虽然不工作)
@browser.file_fIEld(:name => 'file').set("C:\path\to\test\file\valIDTest.xml") 这会导致以下错误
Watir::Exception::UnkNownObjectException: unable to locate element,using {:name=>"file",:tag_name=>"input",:type=>"file"} 试
@browser.button(:ID => 'test').set("C:\path\to\test\file\valIDTest.xml") 导致以下错误
NoMethodError: undefined method `set' for #<Watir::button:0x3859920>
有人可以帮忙吗?我很难理解为什么file_fIEld选项不起作用.
解决方法 尝试使用以下功能:@browser.file_fIEld(:ID,"upload").set("filepath") 此外,如果您使用的是IE浏览器,请确保您使用的是IEDriverServer_Win32_2.33.0,因为它在此驱动程序上运行正常而不是最新的驱动程序.
总结以上是内存溢出为你收集整理的ruby – 使用watir-webdriver选择本地文件全部内容,希望文章能够帮你解决ruby – 使用watir-webdriver选择本地文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)