Browser.upload file by selector don,t get the file from Path

Hi,

Situation is: With Browser Library keyword “Browser.upload file by selector” it is not possible
pick up up the file from path: ${CURDIR}/dubbel_check.jfif

I use the following code:
*** Variables ***
${Add_Choosen_File} ${CURDIR}/dubbel_check.jfif
${UploadFiletest} //input[contains(@type,‘file’) and contains(@id,‘uploadPhotoMulti’)]

*** Keyword***
Upload Pic in Browser Run Keywords
Browser.wait for elements state ${UploadFiletest} state=enabled timeout=60
… AND BuiltIn.sleep 1
… AND Browser.Execute JavaScript window.frames[0]; document.querySelector( “input[id=‘uploadPhotoMulti’]” ).style.display = “block”
… AND BuiltIn.sleep 1
… AND Browser.upload file by selector ${UploadFiletest01} ${Add_Choosen_File}
… AND BuiltIn.sleep 1

UI situation:

DOM stucture:

Anyone have an idea or a suggestion?

Have anyone an idea for this issue?

Hi, Should the keyword “Browser. Upload File By Selector” have the same action as “SeleniumLibrary.Choose File”?

Hi Joost,

I was able to upload a using a double backslash: ${CURDIR}\MyFileName.csv.

Hope this helps.

Hi Jeroen,

The test indicates that is successfully running, but the file is not uploaded from the PATH

I have tried the single/double backslash and the single/double forwardslash for the file from PATH:
${CURDIR}/dubbel_check.jfif

I use xpath: //input[@type=“file”][1]

If I use a wrong path it just states that I have a “Nonexistent input file path”, so I guess that is not the issue.

Looking at your code it seems your test steps end after adding the file and sleeping for a second. Do you need to press “Bevestigen” to actually upload/store the file?

Ok,
I also had that thought, that the file in the PATH is correct
The repro-steps are:
Step 1. I Execute a Java script, so you have the option to choose a file


Step 2. Then upload file from path with keyword “Upload File By Selector”
Step 3. Wait for file to be successfully uploaded
Step 4. Enter a number in the element field “Quantity”
Step 5. After you have entered a number, you can only click on “Bevestigen”

JavaScript I use is:
Browser.Execute JavaScript window.frames[0]; document.querySelector( “input[id=‘uploadPhotoMulti’]” ).style.display = “block”

Hi,

The issue in this item is fixed.
The issue was: That the file being uploaded does not accept all IMG. Like in my case a it not accept a “.jfif” img

I change the file in to a “jpg” file an the file can by succesfully uploaded

Hi,
In addition to the solution: The reason it didn’t work is because robot framework’s browser library uses the node js version of playwright. Before a file is tried to be uploaded, the mime type is checked. So check if the mime type of the file exists in Common MIME types - HTTP | MDN,
Otherwise the file will not be uploaded.