1

html代码如下:

<li>
   <form action="/en/pune/dsf/media/create" enctype="multipart/form-data" method="post">
    <div style="margin: 0px; padding: 0px; display: inline;">
      <input name="authenticity_token" type="hidden" value="DD9PUpCMWTGs66fHEZutO+9RFjcf68xH+T9DMXv1JnA="/>
    </div>
    <div class="media_upload_submit">
      <span class="icon-camera"/>
     <span class="al">Add photos</span>
    </div>
      <input class="media_image_file" data-track="photo_upload,spot_page,user" name="media[image]" type="file"/>
  </form>
</li>

我试过使用

@browser.file_field(:xpath, "//input[@type='file' and @class='media_image_file']/").set "Complete file path name"

但我收到以下错误:

Failure: Unable to locate an element with the xpath expression //input[@type='file' and @class='media_image_file']/ because of the following error:

我尝试过使用许多不同的方法,但得到不同的错误。

4

1 回答 1

1

/后面有一个额外的..and @class='media_image_file']/"。删除它并像这样写:

 @browser.file_field(:xpath, "//input[@type='file' and @class='media_image_file']")
于 2013-09-09T16:22:32.337 回答