Is possible to create new variable in suite/test set up - Robot Framework?

后端 未结 2 432
死守一世寂寞
死守一世寂寞 2021-01-05 10:56

Is it possible to initialize a variable in a suite or test setup based on the return value of a keyword? I\'ve tried this sort of syntax and it didn\'t work:



        
2条回答
  •  攒了一身酷
    2021-01-05 11:31

    Strictly speaking, no, it's not possible. Within a suite or test setup you can only call keywords, you cannot set variables to the result of other keywords directly within the setup statement .

    That being said, it's easy to create a custom setup keyword that does what you want. For example:

    *** Settings ***
    | Suite Setup | Custom suite setup
    
    *** Keywords ***
    | Custom suite setup
    | | ${A Variable}= | Set Variable | A String
    | | Set suite variable | ${A Variable}
    

    The above has the same effect as if robot supported setting variable from keywords directly in the setup. And, of course, you can call any keyword, not just Set Variable.

提交回复
热议问题