2

Suppose I have a generated random alphanumeric character in Test 1(or by using user defined keyword). Now I want to set that random generated value to a variable ${RandomName} (see attached image) and use that variable for other test methods (say Test 2).

How would I go about doing this in Robot Framework?

enter image description here

0

1 Answer 1

3

You can use the keyword Set Suite Variable to make the variable accessible in every test in the current suite:

Set suite variable    ${RandomName}

There is also a keyword named Set global variable which works in a similar manner but makes the variable available to all tests:

Set global variable    ${RandomName}

If you want to create a new variable that is visible everywhere you can do that with Set Suite Variable as well, passing the value as an additional argument.

Set suite variable    ${new variable}    hello, world

The above will create a varnamed named ${new variable} and set it to the string hello, world.

Sign up to request clarification or add additional context in comments.

4 Comments

Though your answer didn't address my question exactly on how I can set random generated value to a variable in robot framework, but it did help me in resolving my scenario exactly what I wanted. Thank you very much.
@ShoaibAkhtar: I added some clarification. You can use the same keyword to make an existing variable available in a suite, but you can use the same keyword to create a new variable.
@ShoaibAkhtar - Will you please provide exact solution to this and how you resolved it .I struck from 2 days in exactly same scenario .Your help is really appreciated.
@ChiragDhingra I moved out from Jmeter project and currently into different roles and feel sorry that I cannot recollect the solution now as it's been long not doing anything related to Jmeter now. I should have posted answer that time itself.

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.