无法使用 Watir 将路径设置为隐藏 file_Field

Can not set path to a hidden file_Field with Watir

我正在使用 Ruby 和 Watir 来测试 UI。 我遇到了一个问题,还没想好怎么解决。

我有一个文件字段元素,其样式为:'display: none',当我尝试设置文件路径时,它 returns 我 "File Not Found message"。 同时很容易确保文件存在。

下面的代码说明了这一点。

0> ff
=> #<Watir::FileField: located: true; {:id=>"fileUpload", :tag_name=>"input", :type=>"file", :index=>0}>

0> path
=> "C:/Users/kpenkin/Documents/watir-tests/specs/test_data.xlsx"

0> File.exist?(path)
=> true

0> Watir.relaxed_locate?
=> false

0> ff.set(path)
=> File not found: C:\Users\kpenkin\Documents\watir-tests\specs\test_data.xlsx

0> ff.wd.send_keys(File.expand_path(path))
=> File not found: C:/Users/kpenkin/Documents/watir-tests/specs/test_data.xlsx

0> ff.exist?
=> true

0> ff.visible?
=> false

这是一个bug in geckodriver。它应该在 chrome 中工作。 看起来它已针对 Firefox 56 修复。