Set Global Variable Keyword Usage

1,449 views
Skip to first unread message

RobotUser

unread,
Sep 29, 2009, 10:55:41 AM9/29/09
to robotframework-users
Hi All,

I'm struck with the usage of Set Global Variable keyword in Ride.

1) I have a variable file as follows which I added to the settings
table of my SampleTest.tsv

def get_variables():
variables = { "var1": "value1",
"var2": "value2"
}
return variables

2) I'm using Set Global Variable in Ride to set the value of a
variable to this file (not sure if I can do that).

Set Global Variable ${newVar} newValue

3) My requirement is that this variable ${newVar} should be added the
variable file used in Step# 2.....is there a possible in Ride/
Robotframework to do that, it would be great if someone can let me
know how to achieve this one?

4) I also tried it from the command line like this

>pybot.bat --variablefile MyVariables.py:newVar:newValue SampleTest.tsv however it did not do the trick of writing it to the py file.

I'm specifically interested in setting it from Ride and any help is
greatly appreciated.

Thanks!
--Waseem

Pekka Klärck

unread,
Sep 29, 2009, 11:20:20 AM9/29/09
to wasee...@gmail.com, robotframework-users
2009/9/29 RobotUser <wasee...@gmail.com>:

>
> I'm struck with the usage of Set Global Variable keyword in Ride.
>
> 1) I have a variable file as follows which I added to the settings
> table of my SampleTest.tsv
>
>    def get_variables():
>    variables = { "var1": "value1",
>                      "var2": "value2"
>                     }
>    return variables
>
> 2) I'm using Set Global Variable in Ride to set the value of a
> variable to this file (not sure if I can do that).
>
> Set Global Variable ${newVar} newValue
>
> 3) My requirement is that this variable ${newVar} should be added the
> variable file used in Step# 2.....is there a possible in Ride/
> Robotframework to do that, it would be great if someone can let me
> know how to achieve this one?

Nope, to achieve that you need to edit your variable file. Set Global
Variable will set a variable at run time.

> 4) I also tried it from the command line like this
>
>>pybot.bat --variablefile MyVariables.py:newVar:newValue SampleTest.tsv however it did not do the trick of writing it to the py file.

This syntax can be used pass arguments to get_variables method in your
variable file [1]. If you just want to create new variables, that
possibly override variables in your variable files, you can use
'--variable newVar:newValue'.

[1] http://robotframework.googlecode.com/svn/tags/robotframework-2.1.1/doc/userguide/RobotFrameworkUserGuide.html#taking-variable-files-into-use

> I'm specifically interested in setting it from Ride and any help is
> greatly appreciated.

You can use Set Global Variable in RIDE but as I wrote above it's only
evaluated when tests are executed.

Cheers,
.peke

Pekka Klärck

unread,
Sep 29, 2009, 4:02:51 PM9/29/09
to Waseem, robotframework-users
2009/9/29 Waseem <wasee...@gmail.com>:
>
> Thanks for your prompt reply.
>
> So does that mean to say there is no keyword to use in Ride to write values
> to an external file?

Yes, this is correct. RIDE doesn't use keywords itself, it just
creates test cases from keywords. Keywords are only "active" when
tests are executed.

It would be possible to implement a plugin to for editing variable
files from RIDE, though. This has even been discussed, but it's not
urgent enough for the core development team currently. Contributions
are highly appreciated of course.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Reply all
Reply to author
Forward
0 new messages