# FAIL FileNotFoundError: [Errno 2] No such file or directory

Hello guys,

I face an issue about the RBFW Keyword “Get File”.
When I launch it on Jenkins, the error below was shown in the log.

## ${Data} = OperatingSystem . Get File${File_Name}, encoding=UTF-8, encoding_errors=strict INFO Getting file ‘[/opt/robotframework/temp/src/resources/Numero_Ticket.txt] (file:///opt/robotframework/temp/src/resources/Numero_Ticket.txt)’.FAIL FileNotFoundError: [Errno 2] No such file or directory: ** ** '/opt/robotframework/temp/src/resources/Numero_Ticket.txt’

the Keyword

UI - Lire Contenu Fichier
${Data} Get File${File_Name} encoding=UTF-8 encoding_errors=strict

NB: ${File_Name} = src//resources//Numero_Ticket.txt Help plz. That was the file it searched for, not the one you intended (src/resources/Numero_Ticket.txt). Because you assumed relative path starting from${CURDIR}/src/…
But Jenkins job started at its workspace, /opt/robotframework/temp/

The solution is for you to provide FULL path to the file (and making sure it exists on the Jenkins node running the job.

1 Like

Thank you for your answer, I have already entered the full path in which I have the file “C://Workspace-score//src//resources//Numero_Ticket.txt” and it displays the same error again.

How can i provide FULL path to the file plz.

Well, when you use / you do not need //. Only when using \ you need \\.

You should use a FULL path when you know the exact location in the Jenkins node (probably not your machine), or use a relative path for example based on the location of the test suite file. There are some default variables for this. for example the ${CURDIR} (and maybe${TESTDIR}, you need to check).

Maybe ${CURDIR}/src/resources/Numero_Ticket.txt works, but you are the only one who can try. You can also map Jenkins node environment variables, like${WORKSPACE}.

3 Likes

Issue resolved thank you so mush

When you open a file with the name “filename.ext”; you are telling the open() function that your file is in the current working directory . This is called a relative path.

file = open('filename.ext') //relative path

In the above code, you are not giving the full path to a file to the open() function, just its name - a relative path. The error “FileNotFoundError: [Errno 2] No such file or directory” is telling you that there is no file of that name in the working directory. So, try using the exact, or absolute path.

file = open(r'C:\path\to\your\filename.ext') //absolute path

In the above code, all of the information needed to locate the file is contained in the path string - absolute path.

After 1 year this still workk! tysm

1 Like