0

I have two objects in robot file created like this.

Library  HwTest   COM17   SN2  WITH NAME  Smart Node 2

Library  HwTest   COM13   SN1  WITH NAME  Smart Node 1 

I need to pass Smart Node 1 and Smart Node 2 in a user defined keyword.

But when I gave the object name after the keyword it was taken as a unicode in python,not as a object. I get error like unicode object has no attribute. AttributeError: 'unicode' object has no attribute 'filename'

2
  • Please show some actual code. It sounds like you shouldn't be passing an object name, you should be passing an actual object. Also, generating objects via Library is a very odd way of doing things. That's not really how Library is supposed to be used. Commented Nov 21, 2019 at 14:17
  • I am completely new to this.My requirement is I need to create two objects in robot framework of a class written in python. And these objects are then passed into a keyword so that the functions associated with the keyword will get these objects from robot. If this is not the right way could you please guide me how to create objects in robot files Commented Nov 22, 2019 at 9:21

1 Answer 1

2

There's not enough detail in your question, but I'm going to make an educated guess that you have a keyword that requires you pass in an object, but you're passing the library name to it, like this:

The keyword  Smart Node 2

If so, that's not how to use keyword libraries in robot. "Smart Node 2" is just the name of the library, not the library itself. If you're trying to use the library as an object then you need to get the instance of that library before passing it to the keyword.

Robot has a built-in keyword named Get library instance which can return the instance of the library. You will need to call that to get the instance, and then pass the instance to your keyword.

Example:

${object}=  Get library instance  Smart Node 2
The keyword  ${object}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.