Hi ,
we are trying to use the robotframework-requests for test web application using REST .. cant able to use the cookie of the login session after /login request ..
any one can able to help in this issue ..
python : Python 2.7.8
pybot --version
Robot Framework 2.8.6 (Python 2.7.8 on win32)
>>> RequestsLibrary._version_
'0.3.8'
Here is my log :
KEYWORD: ${reply} = RequestsLibrary.Get Request session1, /mz/p/v1/troubleshoot/ping, headers=${sess_header}
| Documentation: | Send a GET request on the session object found using the |
|---|
| Start / End / Elapsed: | 20151001 10:12:53.123 / 20151001 10:12:53.235 / 00:00:00.112 |
|---|
| 10:12:53.125 | INFO | Starting new HTTPS connection (1): 10.58.133.101 | |
| 10:12:53.202 | DEBUG | "GET /mz/p/v1/troubleshoot/ping HTTP/1.1" 302 None | |
| 10:12:53.228 | DEBUG | "GET /login.html HTTP/1.1" 200 2599 |
the request needs to go to the cookie session its not going to cookie session...
setting cookie : {u'set-cookie': 'session=QwmuH2vBDxiCynjyoAgMKg.k64UgteMf7aCCCWeFg47TGY5Y3GnZqNANvTddE8ophk.1072916884715.7200000.yKoMdKcRMyN2HR9NkXnUA53KVxdQW0gqpVSf4eW0cE4; path=/; expires=Thu, 01 Jan 2004 02:28:05 GMT; secure; httponly'}
KEYWORD: BuiltIn.Log ${reply.headers}
| Documentation: | Logs the given message with the given level. |
|---|
| Start / End / Elapsed: | 20151001 09:58:54.054 / 20151001 09:58:54.057 / 00:00:00.003 |
|---|
| 09:58:54.056 | INFO | {'content-length': '2599', 'set-cookie': 'session=_VyumCKwR2Bql8V5FBb0pA.etmg7aCDEQ2Pt3xkKijb0txQtfL67rsmEf7RRwblk74.1072916045754.7200000.zP-iBvg_Wcm35JhmppsUTq7hwjRKmZIGTbUqPyCn1ls; path=/; expires=Thu, 01 Jan 2004 02:14:06 GMT; secure; httponly', 'expires': 'Thu, 01 Jan 1970 00:00:00 GMT', 'last-modified': 'Wed, 30 Sep 2015 16:34:39 GMT', 'connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'private, no-cache, no-store, must-revalidate, max-age=0, pre-check=0, post-check=0, public, max-age=3600', 'date': 'Thu, 01 Jan 2004 00:14:05 GMT', 'content-type': 'text/html'} |
Here is my Testcase:
${headers}= Create Dictionary Content-Type application/json
${session} = Create Session session1 https://<server ip> headers=${headers}
${resp}= Post Request session1 /login data={"username":"<username>","password":"<password>"}
${session_cokie} = Create Dictionary set-cookie ${resp.headers['set-cookie']}
${sess_header}= Create Dictionary set-cookie ${resp.headers['set-cookie']} content-type application/json
${session} =
Create Session
session1
https://10.58.133.101 headers=${sess_header}
cookies=${session_cokie}
Should Be Equal As Strings ${resp.status_code} 200
${reply}= Get Request session1 /mz/p/v1/troubleshoot/ping headers=${sess_header}
Regards,
Beno