[英]How to set dynamic value to a variable and use it for other test in robot framework?
Suppose I have a generated random alphanumeric character in Test 1(or by using user defined keyword). 假设我在测试1中有一个生成的随机字母数字字符(或使用用户定义的关键字)。 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). 现在,我想将随机生成的值设置为变量
${RandomName}
(请参见附图),并将该变量用于其他测试方法(例如Test 2)。
How would I go about doing this in Robot Framework? 我将如何在Robot Framework中执行此操作?
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全局变量的关键字,该关键字的工作方式类似,但使该变量可用于所有测试:
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: 如果您想创建一个随处可见的新变量,也可以使用
Set Suite Variable
来做到这一点:
Set global variable ${new variable} ${RandomName}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.