I really love using Watir with Cucumber.  It has some great built in methods.

There’s this awesome method in Watir called file_field.  It basically references any input of type = “file” and follows the prompts to push the file you give through the submit process.

Here’s an example of how I’m doing it:

  @browser.span(:text=>”Upload New”).click
  @browser.file_field(:class=>”UploadSoundfile”).set(“C:\\Users\\Public\\Music\\Sample Music\\Kalimba.mp3”)

For windows to work, I did have to escape the \ with double \\.

But it works like  a charm!

Leave a Reply

Your email address will not be published. Required fields are marked *