1 *** Settings *** 2 Library Collections 3 Library RequestsLibrary 4 5 *** Test Cases *** 6 test 7 Create Session api http://api.github.com 8 Create Session google http://www.google.com 9 ${resp}= Get Request api / 10 ${result} Convert To Integer 200 11 Should Be Equal As Strings ${resp.status_code} ${result} 12 ${resp}= Get Request api /users/bulkan 13 Should Be Equal As Strings ${resp.status_code} ${result} 14 log ${resp.json()} 15 Dictionary Should Contain Value ${resp.json()} User
库介绍:
Keyword |
Arguments |
Documentation |
Create Ntlm Session |
alias, url, auth, headers={}, cookies=None, timeout=None, proxies=None, verify=False |
创建一个HTTP会话: url:即服务器的url alias:使用Robot Framework的别名表示当前会话。 header:使用默认的headers字段 auth:NTLM鉴权需用[‘domain’,’username’,’password’]格式 timeout:会话超时时长 proxies:代理服务器的url verify:如果需要证书请求则置为true |
Create Session |
alias, url, headers={}, cookies=None, auth=None, timeout=None, proxies=None, verify=False |
创建一个HTTP会话: url:即服务器的url alias:使用Robot Framework的别名表示当前会话。 header:使用默认的headers字段 auth:NTLM鉴权需用username&password格式 timeout:会话超时时长 proxies:代理服务器的url verify:如果需要证书请求则置为true |
Delete |
alias, uri, data=(), headers=None, allow_redirects=None |
弃用,查看delete request |
Delete All Sessions |
删除全部的会话 |
|
Delete Request |
alias, uri, data=(), headers=None, allow_redirects=None |
使用别名删除会话 Alias:需要删除的会话的别名 |
Get |
alias, uri, headers=None, params={}, allow_redirects=None |
弃用:使用Get Request |
Get Request |
alias, uri, headers=None, params={}, allow_redirects=None |
根据提供的别名查找会话并在会话中发送GET请求 |
Head |
alias, uri, headers=None, allow_redirects=None |
弃用:使用Head Request |
Head Request |
alias, uri, headers=None, allow_redirects=None |
根据提供的别名查找会话并在会话中发送HEAD请求 |
Options |
alias, uri, headers=None, allow_redirects=None |
弃用:使用Options Request |
Options Request |
alias, uri, headers=None, allow_redirects=None |
根据提供的别名查找会话并在会话中发送Options请求 |
Post |
alias, uri, data={}, headers=None, files={}, allow_redirects=None |
弃用:使用Post Request |
Post Request |
alias, uri, data={}, headers=None, files={}, allow_redirects=None |
根据提供的别名查找会话并在会话中发送POST请求 |
To Json |
content, pretty_print=False |
将返回的数据转换为JSON格式 |