Chose File: File(path) not found

Hello,

I’m trying to upload a certificate to log onto a specific website.
For this task, I decided to use “Chose File”, but for some reason once its supposed to enter the file, it says that the file is not Found under that path.
(The input field does take .pfx files)

This is the Code in question:
*** Settings ***
Library SeleniumLibrary

*** Test Cases ***
Open Google
Open Browser xxxxxxx firefox
Click Link xpath:/html/body/div[1]/div/div/div/main/div/div[1]/div[2]/div/div/div[1]/div/div/div/p/a
Wait Until Element Is Visible id:searchfile

Execute JavaScript    document.querySelector('#certificateFileUploadInput.file-upload__inputFile').style.display='block'; 

This line of code is necessary, as the input field on the site is “greyed out”(disabled probably) but still changes once you use the button. This is the easiest way I’ve found to make it work with choose file.

Choose file   id:certificateFileUploadInput   C:/Users/xxxxxx/Downloads/xxxxx.pfx

Sleep    5s
Input Password    id:standardPassword    xxxxxxxxxx
Sleep    5s
Close Browser

This is the error message from the logs:
InvalidArgumentException: Message: File not found: C:/Users/xxxxxxx/Downloads/xxxxxxx.pfx
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5
InvalidArgumentError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:384:5
interaction.uploadFiles@chrome://remote/content/marionette/interaction.sys.mjs:579:13

I really hope im not being an idiot and this is a genuine problem :sob:, regardless thank you.

Are you using selenium grid or browserstack or something similar ? If yes, you are trying to give a file in your local filesystem but the code that looks for the file is running in remote and ofcourse it can’t find the file.

1 Like

Yeah, I am running a remote-app, but the file is saved on the remote and I can find access it through the windows-explorer on the remote.

I thought it works if the remote machine has it saved on itself as well.
If not, then how can I use it on the remote machine?

selenium itself has Local File and Remote file support but im not familiar with how remote file should work with robot’s selenium bindings… someone else ?

1 Like

So the machine is Windows, and you sure that the path is that when running the test.
I recommend to replace the / by ${/} or even by \\ .

3 Likes

I tried both version and they both worked!
Thank you very much for your help!

2 Likes