No keyword name error displayed while importing from python code in robot framework

Viewed 28

Able to import the python class using the below syntax TestSuite.robot

*** Settings ***
Library  LoginScreen.py


*** Test case ***
TC_01_login tests
    Check Login exists

Pythoncode: LoginScreen.py

from CommonUtils.userdefinedKeywords.commonutils.screen_locators.ScreenLocators import *
from time import sleep
from robot.libraries.BuiltIn import BuiltIn
import unittest
import configparser

class LoginScreen(object):
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

    def __init__(self, package):
        self.driver = BuiltIn().get_library_instance('SeleniumLibrary')
        self.package = package

    def check_login_exists(self):
        sleep(2)
        try:
            self.driver.find_element_by_id(ScreenLocators.username_by_id)
            return True       
        except Exception as e:
            print('Login Windows could not be found by Username Element!')
            return False 

Error:

library 'C:\Users\auto2\PycharmProjects\Web\CommonUtils\userdefinedKeywords\commonutils\screens\LoginScreen.py' failed: ModuleNotFoundError: No module named 'CommonUtils'
Traceback (most recent call last):
  File "C:\Users\auto2\PycharmProjects\Web\CommonUtils\userdefinedKeywords\commonutils\screens\LoginScreen.py", line 9, in <module>
    from CommonUtils.userdefinedKeywords.commonutils.screen_locators.ScreenLocators import *
PYTHONPATH:
  C:\Users\auto2\PycharmProjects\Web\CommonUtils
  C:\Users\auto2\AppData\Roaming\Python\Python39\Scripts\robot.exe
  C:\Program Files\Python\python39.zip
  C:\Program Files\Python\DLLs
  C:\Program Files\Python\lib
  C:\Program Files\Python
  C:\Users\mcpttauto2\AppData\Roaming\Python\Python39\site-packages
  C:\Program Files\Python\lib\site-packages
  ./automation/automation_src/commonutils/screen_locators
tc_01_login to the application with invalid credentials               | FAIL |
No keyword with name 'check login exists' found.
0 Answers
Related