11

I'm creating a testing suite to automate some parts of data input on my web application. I have a page where I can click on a button to upload a document to the application. It looks something like this:

screenshot 1

Once the Add New Attachment button is clicked, it opens the browser's file explorer to select a document to upload. I'm trying to replicate this within Selenium IDE.

Here is what it looks like as of now:

screenshot 2

However, this part seems to fail. Does anyone know how to achieve a similar process using Selenium IDE? I'm on Chrome and Firefox.

Grasshopper
  • 8,908
  • 2
  • 17
  • 32
FlameDra
  • 1,807
  • 7
  • 30
  • 47

2 Answers2

15

If you get the

{"code":-32000,"message":"Not allowed"}

on Chrome, follow the steps below:

Window > More Tools > Extensions > Selenium IDE > Details

Then turn on the 'Allow access to file URLs' option.

I was having the same problem and this worked for me.

Milo
  • 3,365
  • 9
  • 30
  • 44
AndreVitorio
  • 622
  • 1
  • 7
  • 18
5

It is possible to upload the files using selenium IDE. It can be done as mentioned below.

|Command|Target|Value|

|type|target_location_path|location_of_the_file_in_your_system|

Example:

|type|id=ConsignmentCustomerInvoiceFilename|C:\Users\abc\Desktop\img1.jpg|

You can identify the "target_location_path" by manually uploading the file and then finding the xpath of the uploaded file in the web app.

Please refer below screenshot to get a better understanding.

SeleniumIDE_uploadfile

You can add the system path to the IDE test by using the below code.

<tr>
    <td>storeEval</td>
    <td>Preferences.getString(TestSuite.TEST_SUITE_DIRECTORY_PREF);</td>
    <td>testSuiteFolder</td>
</tr>
<tr>
    <td>type</td>
    <td>id=QuestionUpload_file</td>
    <td>${testSuiteFolder}/resources/question_upload.csv</td>
</tr>
Antony Lobo
  • 51
  • 1
  • 4
  • Selenium IDE addon in Chrome says: type on id=files with value C:\\README.txt Failed: {"code":-32000,"message":"Not allowed"} – jmp Apr 16 '19 at 06:20
  • 2
    See the first answer to fix your not allowed issue. – PHPGuru Jun 01 '21 at 17:42