如何将Robot Framework变量传递给JavaScript

时间:2017-07-18 10:29:40

标签: javascript robotframework

我需要将我的Robot变量传递给JavaScript:

${path}=    Set Variable    /apis
${method}=  Set Variable    get
${result}=  Execute Javascript  path_to_file/file.js
Log ${result}   

我想将${path}${method}传递给我的file.js.有可能吗?

1 个答案:

答案 0 :(得分:1)

您需要使用execute javascript来创建javascript变量。

例如:

*** Test Cases ***
Example
    ${path}=    Set Variable    /apis
    ${method}=  Set Variable    get

    Execute javascript  path='foobar';
    Execute javascript  method='${method}'

    ${result}=  Execute Javascript  path_to_file/file.js
    Log ${result}