2016-09-29 30 views
1

我想上传一张watir和phantomjs的图片,但它是失败的。上传文件与watir和phantomjs上OSX

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) 

但它不工作,我有一个网:: ReadTimeout错误。我错在哪里? THX

回答