0

I am trying to upload a txt file to the web application I'm working on, through automation.The application only allows browsing and selecting the file from the local system and it doesn't allow to set the path of the file.Ruby watir-webdriver is the tool used for automating.Can someone help me in automating this.

  • "it doesn't allow to set the path of the file" - how did you find out? What did you do and what happened? – Sergio Tulentsev Jun 14 '18 at 16:37
  • Hi,we have a text field in the application which is read-only and we have a 'Browse' button .So I cannot set the path in the text field .Only browsing the file is possible. – Mariya Jolly Jun 17 '18 at 14:51
  • @browser.text_field(:id=>"uploadBatchFile_text").set("filepath") Watir::Exception::ObjectReadOnlyException: object is read only {:id=>"uploadBatchFile_text", :tag_name=>"input or textarea", :type=>"(any text type)"} – Mariya Jolly Jun 17 '18 at 14:54

1 Answers1

0

It looks like this:

file = "/full/path/to/file.jpg"
browser.file_field(id: "upload-here").set(file)
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
titusfortner
  • 4,099
  • 2
  • 15
  • 29