robotframework接口上传图片

 1     [Arguments]                         ${filePath}=${OTHER_FILE_PATH}
 2     ...                                 ${fileName}=${PHOTO_FILE_NAME}
 3     ...                                 ${fileType}=${JPG_TYPE}
 4     ...                                 ${docLib}=${1}
 5     Create Session                      api    ${ARTICLES_URL}
 6     ${fileContent}      Evaluate       ('${fileName}.${fileType}',open('${filePath}/${fileName}.${fileType}','rb'),'image/${fileType}')
 7     ${fileDict} =                       Create Dictionary   file=${fileContent}
 8     ${bodyData} =                       Create Dictionary   docLib=${docLib}
 9     ${resp} =                           Post Request        api    e5/images/upload     files=${fileDict}   data=${bodyData}
10     #Log             ${resp}
11     Should Be Equal As Strings          ${resp.status_code}     200
12     #Log             ${resp.content}
13     #Log             ${resp.json()}
14     ${responsedata}                     to json             ${resp.content}
15     #Log             ${responsedata}
16     ${data}                             Get From Dictionary                     ${responsedata}    data
17     ${PIC_PATH}                         Get From Dictionary                     ${data}            path
18     # Log             ${PIC_PATH}
19     Set Suite Variable                  ${PIC_PATH}

 

posted @ 2020-06-24 18:04  燕十三丶  阅读(622)  评论(0编辑  收藏  举报
AmazingCounters.com