Skip to content

Commit 724a416

Browse files
authored
Issue #348 - Fix warnings related to the Requests library in automated tests (#349)
1 parent 274953d commit 724a416

File tree

3 files changed

+142
-180
lines changed

3 files changed

+142
-180
lines changed

test/browser-library.robot

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ Library Browser
77
${BROWSER} firefox
88

99
*** Test Cases ***
10-
Visit Baidu
11-
New Browser ${BROWSER}
12-
New Page https://www.baidu.com
13-
Take Screenshot
14-
1510
Visit Bing
1611
New Browser ${BROWSER}
1712
New Page https://www.bing.com

test/requests.robot

Lines changed: 142 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -8,222 +8,193 @@ Suite Teardown Delete All Sessions
88

99
*** Test Cases ***
1010
Get Requests
11-
[Tags] get
12-
Create Session google http://www.google.com
13-
Create Session bing https://www.bing.com verify=True
14-
${resp}= Get Request google /
15-
Should Be Equal As Strings ${resp.status_code} 200
16-
${resp}= Get Request bing /
17-
Should Be Equal As Strings ${resp.status_code} 200
11+
[Tags] get
12+
Create Session google http://www.google.com
13+
Create Session bing https://www.bing.com verify=True
14+
${resp}= GET On Session google /
15+
Should Be Equal As Strings ${resp.status_code} 200
16+
${resp}= GET On Session bing /
17+
Should Be Equal As Strings ${resp.status_code} 200
1818

1919
Get Requests with Url Parameters
20-
[Tags] get
21-
Create Session httpbin http://httpbin.org
22-
&{params}= Create Dictionary key=value key2=value2
23-
${resp}= Get Request httpbin /get params=${params}
24-
Should Be Equal As Strings ${resp.status_code} 200
25-
${jsondata}= To Json ${resp.content}
26-
Should Be Equal ${jsondata['args']} ${params}
20+
[Tags] get
21+
Create Session httpbin http://httpbin.org
22+
&{params}= Create Dictionary key=value key2=value2
23+
${resp}= GET On Session httpbin /get params=${params}
24+
Should Be Equal As Strings ${resp.status_code} 200
25+
Should Be Equal ${resp.json()['args']} ${params}
2726

2827
Get HTTPS & Verify Cert
29-
[Tags] get get-cert
30-
Create Session httpbin https://httpbin.org verify=True
31-
${resp}= Get Request httpbin /get
32-
Should Be Equal As Strings ${resp.status_code} 200
28+
[Tags] get get-cert
29+
Create Session httpbin https://httpbin.org verify=True
30+
${resp}= GET On Session httpbin /get
31+
Should Be Equal As Strings ${resp.status_code} 200
3332

3433
Post Request With URL Params
35-
[Tags] post
36-
Create Session httpbin http://httpbin.org
37-
&{params}= Create Dictionary key=value key2=value2
38-
${resp}= Post Request httpbin /post params=${params}
39-
Should Be Equal As Strings ${resp.status_code} 200
34+
[Tags] post
35+
Create Session httpbin http://httpbin.org
36+
&{params}= Create Dictionary key=value key2=value2
37+
${resp}= POST On Session httpbin /post params=${params}
38+
Should Be Equal As Strings ${resp.status_code} 200
4039

4140
Post Request With No Data
42-
[Tags] post
43-
Create Session httpbin http://httpbin.org
44-
${resp}= Post Request httpbin /post
45-
Should Be Equal As Strings ${resp.status_code} 200
41+
[Tags] post
42+
Create Session httpbin http://httpbin.org
43+
${resp}= POST On Session httpbin /post
44+
Should Be Equal As Strings ${resp.status_code} 200
4645

4746
Put Request With No Data
48-
[Tags] put
49-
Create Session httpbin http://httpbin.org
50-
${resp}= Put Request httpbin /put
51-
Should Be Equal As Strings ${resp.status_code} 200
47+
[Tags] put
48+
Create Session httpbin http://httpbin.org
49+
${resp}= PUT On Session httpbin /put
50+
Should Be Equal As Strings ${resp.status_code} 200
5251

5352
Post Request With No Dictionary
54-
[Tags] post
55-
Create Session httpbin http://httpbin.org debug=3
56-
Set Test Variable ${data} some content
57-
${resp}= Post Request httpbin /post data=${data}
58-
Should Be Equal As Strings ${resp.status_code} 200
59-
Should Contain ${resp.text} ${data}
53+
[Tags] post
54+
Create Session httpbin http://httpbin.org debug=3
55+
Set Test Variable ${data} some content
56+
${resp}= POST On Session httpbin /post data=${data}
57+
Should Be Equal As Strings ${resp.status_code} 200
58+
Should Contain ${resp.text} ${data}
6059

6160
Put Request With URL Params
62-
[Tags] put
63-
Create Session httpbin http://httpbin.org
64-
&{params}= Create Dictionary key=value key2=value2
65-
${resp}= Put Request httpbin /put params=${params}
66-
Should Be Equal As Strings ${resp.status_code} 200
61+
[Tags] put
62+
Create Session httpbin http://httpbin.org
63+
&{params}= Create Dictionary key=value key2=value2
64+
${resp}= PUT On Session httpbin /put params=${params}
65+
Should Be Equal As Strings ${resp.status_code} 200
6766

6867
Put Request With No Dictionary
69-
[Tags] put
70-
Create Session httpbin http://httpbin.org
71-
Set Test Variable ${data} some content
72-
${resp}= Put Request httpbin /put data=${data}
73-
Should Be Equal As Strings ${resp.status_code} 200
74-
Should Contain ${resp.text} ${data}
68+
[Tags] put
69+
Create Session httpbin http://httpbin.org
70+
Set Test Variable ${data} some content
71+
${resp}= PUT On Session httpbin /put data=${data}
72+
Should Be Equal As Strings ${resp.status_code} 200
73+
Should Contain ${resp.text} ${data}
7574

7675
Post Requests
77-
[Tags] post
78-
Create Session httpbin http://httpbin.org
79-
&{data}= Create Dictionary name=bulkan surname=evcimen
80-
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
81-
${resp}= Post Request httpbin /post data=${data} headers=${headers}
82-
Dictionary Should Contain Value ${resp.json()['form']} bulkan
83-
Dictionary Should Contain Value ${resp.json()['form']} evcimen
76+
[Tags] post
77+
Create Session httpbin http://httpbin.org
78+
&{data}= Create Dictionary name=bulkan surname=evcimen
79+
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
80+
${resp}= POST On Session httpbin /post data=${data} headers=${headers}
81+
Dictionary Should Contain Value ${resp.json()['form']} bulkan
82+
Dictionary Should Contain Value ${resp.json()['form']} evcimen
8483

8584
Post With Unicode Data
86-
[Tags] post
87-
Create Session httpbin http://httpbin.org debug=3
88-
&{data}= Create Dictionary name=度假村
89-
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
90-
${resp}= Post Request httpbin /post data=${data} headers=${headers}
91-
Dictionary Should Contain Value ${resp.json()['form']} 度假村
85+
[Tags] post
86+
Create Session httpbin http://httpbin.org debug=3
87+
&{data}= Create Dictionary name=度假村
88+
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
89+
${resp}= POST On Session httpbin /post data=${data} headers=${headers}
90+
Dictionary Should Contain Value ${resp.json()['form']} 度假村
9291

9392
Post Request With Unicode Data
94-
[Tags] post
95-
Create Session httpbin http://httpbin.org debug=3
96-
&{data}= Create Dictionary name=度假村
97-
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
98-
${resp}= Post Request httpbin /post data=${data} headers=${headers}
99-
Dictionary Should Contain Value ${resp.json()['form']} 度假村
93+
[Tags] post
94+
Create Session httpbin http://httpbin.org debug=3
95+
&{data}= Create Dictionary name=度假村
96+
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
97+
${resp}= POST On Session httpbin /post data=${data} headers=${headers}
98+
Dictionary Should Contain Value ${resp.json()['form']} 度假村
10099

101100
Post Request With Data and File
102-
[Tags] post
103-
Create Session httpbin http://httpbin.org
104-
&{data}= Create Dictionary name=mallikarjunarao surname=kosuri
105-
Create File foobar.txt content=foobar
106-
${file_data}= Get File foobar.txt
107-
&{files}= Create Dictionary file=${file_data}
108-
${resp}= Post Request httpbin /post files=${files} data=${data}
109-
Should Be Equal As Strings ${resp.status_code} 200
101+
[Tags] post
102+
Create Session httpbin http://httpbin.org
103+
&{data}= Create Dictionary name=mallikarjunarao surname=kosuri
104+
Create File foobar.txt content=foobar
105+
${file_data}= Get File foobar.txt
106+
&{files}= Create Dictionary file=${file_data}
107+
${resp}= POST On Session httpbin /post files=${files} data=${data}
108+
Should Be Equal As Strings ${resp.status_code} 200
110109

111110
Put Requests
112-
[Tags] put
113-
Create Session httpbin http://httpbin.org
114-
&{data}= Create Dictionary name=bulkan surname=evcimen
115-
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
116-
${resp}= Put Request httpbin /put data=${data} headers=${headers}
117-
Dictionary Should Contain Value ${resp.json()['form']} bulkan
118-
Dictionary Should Contain Value ${resp.json()['form']} evcimen
111+
[Tags] put
112+
Create Session httpbin http://httpbin.org
113+
&{data}= Create Dictionary name=bulkan surname=evcimen
114+
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
115+
${resp}= PUT On Session httpbin /put data=${data} headers=${headers}
116+
Dictionary Should Contain Value ${resp.json()['form']} bulkan
117+
Dictionary Should Contain Value ${resp.json()['form']} evcimen
119118

120119
Head Request
121-
[Tags] head
122-
Create Session httpbin http://httpbin.org
123-
${resp}= Head Request httpbin /headers
124-
Should Be Equal As Strings ${resp.status_code} 200
120+
[Tags] head
121+
Create Session httpbin http://httpbin.org
122+
${resp}= HEAD On Session httpbin /headers
123+
Should Be Equal As Strings ${resp.status_code} 200
125124

126125
Options Request
127-
[Tags] options
128-
Create Session httpbin http://httpbin.org
129-
${resp}= Options Request httpbin /headers
130-
Should Be Equal As Strings ${resp.status_code} 200
131-
Dictionary Should Contain Key ${resp.headers} allow
126+
[Tags] options
127+
Create Session httpbin http://httpbin.org
128+
${resp}= OPTIONS On Session httpbin /headers
129+
Should Be Equal As Strings ${resp.status_code} 200
130+
Dictionary Should Contain Key ${resp.headers} allow
132131

133132
Delete Request With URL Params
134-
[Tags] delete
135-
Create Session httpbin http://httpbin.org
136-
&{params}= Create Dictionary key=value key2=value2
137-
${resp}= Delete Request httpbin /delete ${params}
138-
Should Be Equal As Strings ${resp.status_code} 200
133+
[Tags] delete
134+
Create Session httpbin http://httpbin.org
135+
${resp}= DELETE On Session httpbin url=/delete?key=value&key2=value2
136+
Should Be Equal As Strings ${resp.status_code} 200
139137

140138
Delete Request With No Data
141-
[Tags] delete
142-
Create Session httpbin http://httpbin.org
143-
${resp}= Delete Request httpbin /delete
144-
Should Be Equal As Strings ${resp.status_code} 200
139+
[Tags] delete
140+
Create Session httpbin http://httpbin.org
141+
${resp}= DELETE On Session httpbin /delete
142+
Should Be Equal As Strings ${resp.status_code} 200
145143

146144
Delete Request With Data
147-
[Tags] delete
148-
Create Session httpbin http://httpbin.org debug=3
149-
&{data}= Create Dictionary name=bulkan surname=evcimen
150-
${resp}= Delete Request httpbin /delete data=${data}
151-
Should Be Equal As Strings ${resp.status_code} 200
152-
Log ${resp.content}
153-
Comment Dictionary Should Contain Value ${resp.json()['data']} bulkan
154-
Comment Dictionary Should Contain Value ${resp.json()['data']} evcimen
145+
[Tags] delete
146+
Create Session httpbin http://httpbin.org debug=3
147+
&{data}= Create Dictionary name=bulkan surname=evcimen
148+
${resp}= DELETE On Session httpbin /delete data=${data}
149+
Should Be Equal As Strings ${resp.status_code} 200
150+
Log ${resp.content}
151+
Comment Dictionary Should Contain Value ${resp.json()['data']} bulkan
152+
Comment Dictionary Should Contain Value ${resp.json()['data']} evcimen
155153

156154
Patch Requests
157-
[Tags] patch
158-
Create Session httpbin http://httpbin.org
159-
&{data}= Create Dictionary name=bulkan surname=evcimen
160-
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
161-
${resp}= Patch Request httpbin /patch data=${data} headers=${headers}
162-
Dictionary Should Contain Value ${resp.json()['form']} bulkan
163-
Dictionary Should Contain Value ${resp.json()['form']} evcimen
155+
[Tags] patch
156+
Create Session httpbin http://httpbin.org
157+
&{data}= Create Dictionary name=bulkan surname=evcimen
158+
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
159+
${resp}= PATCH On Session httpbin /patch data=${data} headers=${headers}
160+
Dictionary Should Contain Value ${resp.json()['form']} bulkan
161+
Dictionary Should Contain Value ${resp.json()['form']} evcimen
164162

165163
Post Request With Redirection
166-
[Tags] post
167-
Create Session jigsaw http://jigsaw.w3.org
168-
${resp}= Post Request jigsaw /HTTP/300/302.html
169-
Should Be Equal As Strings ${resp.status_code} 200
170-
${resp}= Post Request jigsaw /HTTP/300/302.html allow_redirects=${true}
171-
Should Be Equal As Strings ${resp.status_code} 200
164+
[Tags] post
165+
Create Session jigsaw http://jigsaw.w3.org
166+
${resp}= POST On Session jigsaw /HTTP/300/302.html
167+
Should Be Equal As Strings ${resp.status_code} 200
168+
${resp}= POST On Session jigsaw /HTTP/300/302.html allow_redirects=${true}
169+
Should Be Equal As Strings ${resp.status_code} 200
172170

173171
Post Request Without Redirection
174-
[Tags] post
175-
Create Session jigsaw http://jigsaw.w3.org debug=3
176-
${resp}= Post Request jigsaw /HTTP/300/302.html allow_redirects=${false}
177-
${status}= Convert To String ${resp.status_code}
178-
Should Start With ${status} 30
172+
[Tags] post
173+
Create Session jigsaw http://jigsaw.w3.org debug=3
174+
${resp}= POST On Session jigsaw /HTTP/300/302.html allow_redirects=${false}
175+
${status}= Convert To String ${resp.status_code}
176+
Should Start With ${status} 30
179177

180178
Put Request With Redirection
181-
[Tags] put
182-
Create Session jigsaw http://jigsaw.w3.org debug=3
183-
${resp}= Put Request jigsaw /HTTP/300/302.html
184-
Should Be Equal As Strings ${resp.status_code} 200
185-
${resp}= Put Request jigsaw /HTTP/300/302.html allow_redirects=${true}
186-
Should Be Equal As Strings ${resp.status_code} 200
179+
[Tags] put
180+
Create Session jigsaw http://jigsaw.w3.org debug=3
181+
${resp}= PUT On Session jigsaw /HTTP/300/302.html
182+
Should Be Equal As Strings ${resp.status_code} 200
183+
${resp}= PUT On Session jigsaw /HTTP/300/302.html allow_redirects=${true}
184+
Should Be Equal As Strings ${resp.status_code} 200
187185

188186
Put Request Without Redirection
189-
[Tags] put
190-
Create Session jigsaw http://jigsaw.w3.org
191-
${resp}= Put Request jigsaw /HTTP/300/302.html allow_redirects=${false}
192-
${status}= Convert To String ${resp.status_code}
193-
Should Start With ${status} 30
187+
[Tags] put
188+
Create Session jigsaw http://jigsaw.w3.org
189+
${resp}= PUT On Session jigsaw /HTTP/300/302.html allow_redirects=${false}
190+
${status}= Convert To String ${resp.status_code}
191+
Should Start With ${status} 30
194192

195193
Do Not Pretty Print a JSON object
196-
[Tags] json
197-
Comment Define json variable.
198-
Create Session httpbin http://httpbin.org
199-
&{var}= Create Dictionary key_one=true key_two=this is a test string
200-
${resp}= Get Request httpbin /get params=${var}
201-
Should Be Equal As Strings ${resp.status_code} 200
202-
${jsondata}= To Json ${resp.content}
203-
Dictionaries Should Be Equal ${jsondata['args']} ${var}
204-
205-
Pretty Print a JSON object
206-
[Tags] json
207-
Comment Define json variable.
208-
Create Session httpbin http://httpbin.org
209-
&{var}= Create Dictionary key_one=true key_two=this is a test string
210-
${resp}= Get Request httpbin /get params=${var}
211-
Log ${resp}
212-
${output}= To Json ${resp.content} pretty_print=True
213-
Log ${output}
214-
Should Contain ${output} "key_one": "true"
215-
Should Contain ${output} "key_two": "this is a test string"
216-
Should Not Contain ${output} {u'key_two': u'this is a test string', u'key_one': u'true'}
217-
218-
Set Pretty Print to non-Boolean value
219-
[Tags] json
220-
Comment Define json variable.
221-
Create Session httpbin http://httpbin.org
222-
&{var}= Create Dictionary key_one=true key_two=this is a test string
223-
${resp}= Get Request httpbin /get params=${var}
224-
Log ${resp}
225-
${output}= To Json ${resp.content} pretty_print="Hello"
226-
Log ${output}
227-
Should Contain ${output} "key_one": "true"
228-
Should Contain ${output} "key_two": "this is a test string"
229-
Should Not Contain ${output} {u'key_two': u'this is a test string', u'key_one': u'true'}
194+
[Tags] json
195+
Comment Define json variable.
196+
Create Session httpbin http://httpbin.org
197+
&{var}= Create Dictionary key_one=true key_two=this is a test string
198+
${resp}= GET On Session httpbin /get params=${var}
199+
Should Be Equal As Strings ${resp.status_code} 200
200+
Dictionaries Should Be Equal ${resp.json()['args']} ${var}

test/selenium.robot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ Library SeleniumLibrary
55
${BROWSER} %{BROWSER}
66

77
*** Test Cases ***
8-
Visit Baidu
9-
Open Browser https://www.baidu.com ${BROWSER}
10-
Capture Page Screenshot
11-
128
Visit Bing
139
Open Browser https://www.bing.com ${BROWSER}
1410
Capture Page Screenshot

0 commit comments

Comments
 (0)