Robotframework 无法在[setup]robot框架中创建变量
我试图在测试设置中创建一个变量,但它出错了Robotframework 无法在[setup]robot框架中创建变量,robotframework,Robotframework,我试图在测试设置中创建一个变量,但它出错了 *** Test Cases *** Set Volume Normalisation Level [Setup] Run Keywords ${is_exist}= Get Exist Element ... AND Pass Execution If "${is_exist}" == "True" Ele
*** Test Cases ***
Set Volume Normalisation Level
[Setup] Run Keywords ${is_exist}= Get Exist Element
... AND Pass Execution If "${is_exist}" == "True" Element is not exist
[Template] Set Volume Normalisation Level
value=25 actual_value=25
value=50 actual_value=50
value=75 actual_value=75
value=100 actual_value=100
*** Keywords ***
Get Exist Element
${present}= Run Keyword And Return Status Page Should Contain Element xpath://div[text()="Normalization"]
Return From Keyword ${present}
Set Volume Normalisation Level
[Arguments] ${value} ${actual_value}
Drag Vol Norm Slider To ${value}
Sleep .5
Vol Norm Slider Value Should Be ${actual_value}
=>未找到变量${is_exist}
虽然我尝试使用Set Test变量,但它不适用于关键字
*** Test Cases ***
[Setup] Run Keywords Set Test Variable ${is_exist} Get Exist Element
... AND Pass Execution If "${is_exist}" == "True" Element is not exist
=>${is_exist}
获取字符串值:获取exist元素
如何在测试设置中创建变量从关键字获取值最简单的方法是创建一个新的用户关键字,而不是使用
运行关键字。以您的情况为例:
*** Keywords ***
My Test Setup Keyword
${is_exist}= Get Exist Element
Pass Execution If "${is_exist}" == "True" Element is not exist
*** Test Cases ***
Set Volume Normalisation Level
[Setup] My Test Setup Keyword
# Rest of the test case
令人惊叹的。这是最简单的方法!顺便说一下,我的目的是忽略模板和拆卸如果关键字在安装返回假。我试着在模板和拆卸中运行关键字Get Exist元素。成功了。还有更好的办法吗?非常感谢你@我认为HieuNguyen在设置中这样做是最好的方式。这是在测试运行之前进行决策和准备的正确位置。