[RIDE] How to import the python datetime module

352 views
Skip to first unread message

Avihay Eyal

unread,
Sep 11, 2013, 8:52:06 AM9/11/13
to robotframe...@googlegroups.com
Hi, I'm trying to call the Evaluate keyword, with a python expression using the datetime module (I'm trying to get the local time,
and subtract certain amount of minutes from it). The problem is that the datetime module is not recognized. I receive this error:

failed: NameError: name 'datetime' is not defined

I tried to import the datetime module as a Library in the testsuite definitions, but RIDE fails to import it. It says it needs

What's the right way to use the datetime module

Tatu Aalto

unread,
Sep 11, 2013, 2:21:04 PM9/11/13
to aviha...@gmail.com, robotframe...@googlegroups.com
Ugh

Best way would be to make a library [1] from your code use it as a
keyword from Robot Framework

-Tatu
[1]
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.1#creating-test-libraries
> --
> You received this message because you are subscribed to the Google
> Groups "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to robotframework-u...@googlegroups.com.
> To post to this group, send email to
> robotframe...@googlegroups.com.
> Visit this group at http://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/groups/opt_out.

Kevin O.

unread,
Sep 11, 2013, 6:42:03 PM9/11/13
to robotframe...@googlegroups.com
With evaluate you can name modules for the modules argument, but not classes in modules like datetime.datetime. Perhaps you are doing this?
${now}=    Evaluate    datetime.now()    datetime.datetime
When you should do
${now}=    Evaluate    datetime.datetime.now()    datetime

Avihay Eyal

unread,
Jan 29, 2014, 8:05:49 AM1/29/14
to robotframe...@googlegroups.com
Thanks, you're right, I missed it.
Reply all
Reply to author
Forward
0 new messages