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:
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:
However, this part seems to fail. Does anyone know how to achieve a similar process using Selenium IDE? I'm on Chrome and Firefox.
From the menu bar, select File > Import Selenium IDE Project and browse your Selenium IDE file (a single file with a . side extension) to open.
We can upload files using Selenium Webdriver. This is achieved by the sendKeys method. We have to first identify the element which performs the file selection by mentioning the file path [to be uploaded].
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With