rjha
rjha

Reputation: 148

Robot Framework Custom Library Imports using WITH NAME

I have recently started using Robot Framework for my Automation Framework, using my existing python Libraries

*** Settings *** 
Library ../../lib/ServerAPI.py WITH NAME ServerAPI 

*** Test Cases *** 
[TC-001]-Registering a device with INVALID SUBSCRIBER name to the server
      ServerAPI.subscriber None
      ${resp} register device ${token} ${devid}
      LOG ${resp}
      Should Be Equal ${resp} ${True}`

Its not recognising the ServerAPI keyword name for the library, can anybody help me, what i'm missing here?

Upvotes: 1

Views: 2085

Answers (2)

rjha
rjha

Reputation: 148

This issue resolved, it seems i was importing the .py file in my robot testcase, so WITH NAME it was not taking. I tried using the classname mentioned in the py file and added the path in PYTHONPATH, now its working. Thanks for all the suggestion

Library  ServerAPI  WITH NAME  serverApi

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 385870

Based on the code in the question, it appears that you do not have the proper number of spaces before "WITH" and after "NAME" -- "WITH NAME" needs at least two spaces before and after (though, if you are using tabs, that may not be the problem).

For example:

*** Settings *** 
Library ../../lib/ServerAPI.py  WITH NAME  ServerAPI 

Upvotes: 0

Related Questions