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}.

2 Likes

Issue resolved thank you so mush :+1: