I have created a Robot Framework custom keyword in a python script that returns the full file paths of files in a directory structure. I can run the python script separately and I get the expected results, however, when I use the script as a custom keyword the returned list in empty.
Any help is appreciated See below for code: ROBOT CODE
Settings
Library FilePaths.py
Test Cases
GetsubmissionFiles
@{List}= get filepaths ////SomeServer//D//TestData//Automation//UK//
Here is the python code:
import os
class FilePaths:
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
d = "\\\\SomeServer\\D\\TestData\\Automation\\UK\\"
def get_filepaths(d):
file_paths = []
for root, directories, files in os.walk(d):
for filename in files:
filepath = os.path.join(root, filename)
file_paths.append(filepath)
return file_paths
full_file_paths = get_filepaths(d)
print(full_file_paths)
Issue is Robot Framework results in an empty list value with none of the file paths Return value = []
get_filepaths()definition? It's not a class method, but a function; and as there is a class with the same name as the file - Robotframework will import it (the class) and expose all its methods as keywords, and will not do the same for other functions in the file.////SomeServer//D//TestData//Automation//UK//is not a valid path. It's also not the same as the one you use in the python script (backslashes are very different from forward slashes) so it's wrong to conclude that it works when you call it from python but not when called from robot.