Hi,
i am getting “No keyword with name ‘From Pdf’ found” on try to get list from pdf file.
it works when i run python file separately and getting the error when call to python file form Robot.
Robot recognize python file and display def from_pdf()->Tuple(str, …) when ctr+mouse point.
In this scenario, new pdf file automatically saved on the pc → robot call to read data and then delete file. I found, if old pdf file was deleted after robot script was started, then new pdf file was saved successfully and there is no “No keyword with name…” error but robot display old file information (don’t understand why) … if old pdf file was deleted before robot script was started, then “No keyword with name…” message on try to read PDf file via python file.
Can anyone help me to resolve this?
I found, that i am getting this error for all python file with ‘return’ value … at the same time, there is no error for executable only python file
Here is code:
Library PDFReturn.py
Variables PDFReturn.py
robot.robot
Extract from PDF
@{pdf_return} From Pdf
Set Suite Variable @{pdf_return} {status} Set Global Variable @{pdf_return_status[0]}
{phone} Set Global Variable @{pdf_return_status[1]}
PDFReturn.py
def from_pdf() :
var1 = some data from PDF file
var2 = some data from PDF file
returnVariable=(var1, var2)
return returnVariable
The path to PDFReturn.py is correct. I tried to create a class and got the same result. After trying many scenarios, I am guessing that the problem might be related to the python file structure. My python file has variables declared at the top and before the method name, like
var1 = none
var2 = none
def from_pdf ():
var1 = some data from PDF file
var2 = some data from PDF file
returnVariable = (var1, var2)
return returnVariable
I stopped getting the “No keyword … not found” error after removing the “var1 / 2 = none” variables. I still don’t know if there are any Python file structure requirements for working with a robot framework.
I need to redo a Python file to see if it will work.
Also: i use libraries with in capital letter as class library not as module library. Not sure if python or robot have a similar assumption. I would try to build it like that and rename the library:
Library pdf_return.py
Variables configuration.py
Module libraries cannot be shared with other projects, therefore I hardly ever use them. Class libraries have the same implementation effort, but they can be easily transferred in to a separate library project:
from robot.api.deco import library
@library
class PDFReturn:
var1 = none
var2 = none
def from_pdf (self):
self.var1 = some data from PDF file
self,var2 = some data from PDF file
returnVariable = (var1, var2)
return returnVariable
New observation. The code started working after I reworked the Python file.
Then I added changes to the second python file and only tested it in python, however after running the code from the robot framework I start to get a “No keyword … not found” message associated with the second python file. The error disappeared after rolling back latte changes. It looks like error message was misinformed me and I need to find the problem in the python file. I’m trying to debug by adding messages and breakpoints to a python file, but that doesn’t work. I need to learn how to debug an RF, RF + python file. Please advise a few steps / methods / tools on how to do this.