1
votes

I have seen a few questions here on stack that relate to this topic and like the other questions the responses seem to always include RC/WD solutions. this is for SELENIUM IDE, not the WD/RC implementations.

I realize that we just need to set the value of the element that stores the file path, but I am seeing conflicting ways of doing it.

My element that stores the string of the file path looks like this under the inspector:

input type="file" name="StdConditionsFile" id="pdfApp"

If I get the Xpath of the element it looks like this:

//*[@id="pdfApp"]

I am using the following code to assign the file.path:

  • Command: type
  • Target: id=idOfFileInput
  • Value: /full/path/to/uploadfile

But I am having no luck. I tried using the name, xpath and id of the element but the file.path is never assigned.

Update: I am finding some progress but it might be misleading as to if I can actually do this. Instead of using 'type' as the command I looked for another alternate and found 'setElementAttribute'. If I use that command with either the Id, name or XPath of the upload.element I can see that I am actually setting the value, however there is a catch to this.

After I run any of those 3 commands I see this in the inspector:

input name="StdConditionsFile" id="pdfApp" value="C:\full\path\of\file\filename.pdf" style="" type="file"

Where it is like this before running the commands

input name="StdConditionsFile" id="pdfApp" style="" type="file"

but when you look at the DOM properties, the attribute called 'value' is "" or null.

Anyone actually have any success with this?

1

1 Answers

0
votes

I was able to do this with the use of AutoIt. I created a script in AutoIt that I had to start before I started the tests/testsuite in Selenium IDE. The AutoIt script would loop while looking for a "File Upload" window. The exact steps were:

  1. Create the AutoIt script that looped and looked for a window called "File Upload"
  2. Started the AutoIt script
  3. Started the Selenium IDE test scripts
  4. The Selenium IDE script would do it's stuff, click the "Browse" button on the website page and pause.
  5. The looping AutoIt script would see the "File Upload" window that was produced in the previous step from Selenium IDE and enter in the path of the upload file in the dialog window (browse -> file upload)
  6. AutoIt would then click "Ok" and close the upload window
  7. The Selenium IDE script would come out of it's pause and click the "Upload" button on the website.
  8. File uploaded! - Check!

Testing/Troubleshooting: I used the exact same command in Selenium WD and Selenium IDE where I used "Sendkeys" to enter in the filepath into the upload control on the site. Selenium IDE would say that the command was successful, but you never saw the website update and show the path like it would for WD. Thus, when you click the upload button, no file was ever uploaded. I tried this on multipe machines and with using "Type". That also did not work and the command in Selenium IDE showed as a pass. I also use setElementAttribute which passed in the IDE but did not work. Other users say this work, but I have yet to see it and AutoIt for sure works.