user8162
user8162

Reputation: 221

Defining a lengthy text to a variable in Robot Framework

I would like to define a lengthy text to a variable and use the same text to paste in website field.

For Eg.

${Text} Hi, How are you. Here i am going to type some random text. This is then second paragraph of the text.This is the third paragraph of the text. Thanks & regards, Tester

If I define like the above way ${text}, I am getting only "Hi," for this variable. It would be great, if anyone could let me know the way to define this lengthy text.

Sorry for this question. I am new to robot framework.

Upvotes: 0

Views: 1470

Answers (1)

Helio
Helio

Reputation: 3737

Looks like you are using two spaces as the separator for keywords and data. Try to use four spaces, and then those two spaces in the content should not cause separation.

For an easier way to make sure the variable is correctly defined, you can use a YAML or Python variables file. Here is the example for Python:

Text = "Hi, How are you. Here i am going to type some random text. This is then second paragraph of the text.This is the third paragraph of the text. Thanks & regards, Tester"

And you import like this (assuming the file is named my_vars.py):

*** Settings ***
Variables         my_vars.py

Another possibility is to use the assignment in a step or keyword, but taking care with the scope for the variable definition, for example:

${Text}=    Set Variable    "Hi, How are you. Here i am going to type some random text. This is then second paragraph of the text.This is the third paragraph of the text. Thanks & regards, Tester"

Or

Set Suite Variable    ${Text}    "Hi, How are you. Here i am going to type some random text. This is then second paragraph of the text.This is the third paragraph of the text. Thanks & regards, Tester"

Upvotes: 1

Related Questions