[英]Robot Framework accessing a keyword from test suite Metadata
I want to set for each test inside the test suite a simple report of the computer name, So I've created the following simple robot __init__.robot
file: 我想为测试套件内的每个测试设置一个简单的计算机名称报告,因此,我创建了以下简单的机械手
__init__.robot
文件:
*** Settings ***
Metadata Executed At Get Environment Variable COMPUTERNAME
Library OperatingSystem
The problem is that the Get Environment Variable
is translated as a string instead of calling the keyword Get Environment Variable
with the argument COMPUTERNAME
问题在于,将“
Get Environment Variable
转换为字符串,而不是使用参数COMPUTERNAME
调用关键字“ Get Environment Variable
”
The log put is: Executed At: Get Environment Variable COMPUTERNAME
放置的日志为:
Executed At: Get Environment Variable COMPUTERNAME
Question: How can i call some keyword from the settings Metadata
? 问题:如何从“
Metadata
”设置中调用某些关键字?
If you are asking about how to call a keyword in the Metadata
setting, the answer is that you can't. 如果您询问如何在
Metadata
设置中调用关键字,答案是您不能。 What you can do, however, is call a keyword that sets the metadata. 但是,您可以做的是调用设置元数据的关键字。 Within the
Metadata
setting, however, you can only define strings. 但是,在“
Metadata
设置中,您只能定义字符串。
To set the metadata via a keyword is a two step process: first, call a keyword and save the return value, and then call the Set Suite Metadata keyword. 通过关键字设置元数据的过程分为两个步骤:首先,调用关键字并保存返回值,然后调用Set Suite Metadata关键字。 You can do this in a Suite Setup by creating a custom keyword:
您可以在Suite安装程序中通过创建自定义关键字来执行此操作:
*** Settings ***
Suite setup Initialize Metadata
*** Keywords ***
Initialize Metadata
${data}= Get environment variable COMPUTERNAME
Set suite metadata Executed At ${data}
If your real problem is simply that you want to set metadata based on an environment variable, use the environment variable syntax : 如果您真正的问题只是想基于环境变量设置元数据,请使用环境变量语法 :
*** Settings ***
Metadata %{COMPUTERNAME}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.