我正在尝试使用watir和phantomjs上传图片,但它失败了。
Html代码是:
<div class="qq-uploader">
<div class="qq-upload-drop-area" style="display: none;">
<span>Drop files here to upload</span>
</div>
<div class="qq-upload-button" style="position: relative; overflow: hidden; direction: ltr;">
<div>Click or Drop for upload images</div>
<input multiple="multiple" type="file" name="qqfile">
</div>
<span class="qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list"></ul>
</div>
</div>
我试过
require 'phantomjs'
require 'watir'
require 'watir-webdriver'
Selenium::WebDriver::PhantomJS.path = '/phantomjs/bin/phantomjs'
b = Watir::Browser.new(:phantomjs)
b.goto("http://website.com")
b.text_field(:name => /title/).set 'My title'
b.div(:id => "restricted-fine-uploader").fire_event :click
file = "/Users/Tom/Pictures/image.jpg"
b.file_field.set(file)
和
b.div(:id => "restricted-fine-uploader").fire_event :click
file = "/Users/Tom/Pictures/image.jpg"
b.file_field(:name => "qqfile").set(file)
但它不起作用,我有一个Net :: ReadTimeout错误。我哪里错了? THX
答案 0 :(得分:1)
是的,这是一个已知的phantomjs错误:https://github.com/detro/ghostdriver/issues/183
Phantomjs司机多年来一直没有积极维护。 Selenium团队通常建议不要将其用于测试。