Passing multiple files to input node with Watir (using Ruby)

前端 未结 1 1020
庸人自扰
庸人自扰 2021-01-23 18:41

So I have hit a bit of a snag. I am trying to automate a test case where I need to pass multiple files to an input node and I cannot figure out how to do so. I can use either

1条回答
  •  Happy的楠姐
    2021-01-23 19:35

    Currently there doesn't seem to be a workaround for Firefox. If anybody knows of one, please post the answer as I couldn't find a solution anywhere. I figured I'd post the solution for Chrome here because resources are scarce on this.

    If you need to test for multiple file uploads, have that particular instance load the Chrome driver with:

    @browser = Watir::Browser.new :chrome, :prefs => profile
    

    Then you're going to want to pass it a string that looks something like this:

    paths = "path/to/first/file.json\npath/to/second/file.json\n...etc
    file_field.send_keys paths
    

    0 讨论(0)
提交回复
热议问题