How to load a json data file into a variable in robot framework?

后端 未结 5 1651
庸人自扰
庸人自扰 2021-01-02 18:16

I Am trying to load a json data file into a variable directly in Robot Framework. Can anyone please elaborate with an e.g. giving the exact syntax as to how to do it? Thanks

5条回答
  •  长发绾君心
    2021-01-02 18:57

    A common use is passing the json data to another library like Http Library Requests. You could do:

    *** Settings ***
    Library        OperatingSystem
    Library        RequestsLibrary
    
    *** Test Cases ****
    Create User
             #...
       ${file_data}= 
        ...  Get Binary File    ${RESOURCES}${/}normal_user.json
             Post Request       example_session    /user    data=${file_data} 
             #...
    

    No direct python involved and no intermediary json object.

提交回复
热议问题