无法在 [setup] 机器人框架中创建变量
Can not create variable in [setup] robot framework
我试图在测试设置中创建一个变量,但它出错了
*** 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 Variable 但它对关键字无效
*** 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}
获取字符串值:获取现有元素
如何在测试设置中创建变量从关键字
获取值
最简单的方法是创建一个新的用户关键字而不是使用 Run Keywords
。例如你的情况:
*** 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
我试图在测试设置中创建一个变量,但它出错了
*** 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 Variable 但它对关键字无效
*** 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}
获取字符串值:获取现有元素
如何在测试设置中创建变量从关键字
最简单的方法是创建一个新的用户关键字而不是使用 Run Keywords
。例如你的情况:
*** 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