0
votes

I am trying to call Python file from Robot file where I am getting error as

on line 2: Importing library 'Custom_lib.CustomLib' failed: ModuleNotFoundError: No module named 'Custom_lib'

Below is content of my "Custom_lib.py" file,

from robot.api.deco import keyword

class Custom_lib:

        ROBOT_LIBRARY_SCOPE = 'TEST CASE'

        @keyword
        def get_my_message(self):
                word = "Hello World"
                return word

This is "my.robot" file,

*** Settings ***
Library  Custom_lib.py


 
*** Test Cases ***
call python
    ${SEARCH}   =   Get My Message
    log  ${SEARCH}

when I try to run my robot file with the command : robot my.robot

Importing library 'Custom_lib.CustomLib' failed: ModuleNotFoundError: No module named 'Custom_lib'

can anyone please help me to resolve this, really apreciated.

1

1 Answers

0
votes

I have just tested your code and it worked, as long as Custom_lib.py is in the same directory of my.robot. Only needed to remove spacing at keyword call:

*** Settings ***
Library           Custom_lib.py

*** Test Cases ***
call python
    ${SEARCH}=    Get My Message
    log    ${SEARCH}