Passing / storing python objects in RobotFramework variables

2,127 views
Skip to first unread message

Joshua Henn

unread,
May 12, 2012, 11:11:32 PM5/12/12
to robotframe...@googlegroups.com
I want to be able to pass and store python objects in variables, see
example below:


Lib.py
--------

class Test(object):
pass

def getTest():
return Test()

def displayVar(var):
print type(var)

---------

*** Settings ***
Library Lib.py

*** Testcases ***
Test Passing Python Objects in RF Variables
${var}= Get Test
Display Var ${var}

-----

Expected result:
<type 'Test'>

Actual:
<type 'str'>

---

Is it possible to pass to pass / store native python classes in
variables? So far it looks like they get converted to strings..

Thanks,

Josh

Joshua Henn

unread,
May 13, 2012, 12:08:22 AM5/13/12
to robotframework-users
My mistake, it does appear that RobotFramework can infact pass/store
python classes.. After actually running my own example. I had another
piece of code that was converting it to a string, so I assumed that it
wasn't working.

The mystery still remains on why one of my other pieces of code is
converting it to a string. Maybe I have an extra space in the
argument somewhere and it things I am concat'ing a object and a
string?

smysnk

unread,
May 13, 2012, 1:11:48 AM5/13/12
to robotframe...@googlegroups.com
Ahh.  It all makes sense now.. (I was going crazy there for a second)

I finally clued in to the fact I was trying to store a python class from a remote library, and then send it back again (I know it sounds absurd..shhh).

The solution I think is I will have to maintain some type of variable store on the remote library and use keys to access them again.
Reply all
Reply to author
Forward
0 new messages