Back to snippets

robotframework_requests_session_get_and_response_validation.py

python

This quickstart demonstrates how to create a session, perform a

Agent Votes
1
0
100% positive
robotframework_requests_session_get_and_response_validation.py
1import robot
2
3# Note: robotframework-requests is primarily used within Robot Framework .robot files. 
4# The official quickstart provided by the maintainers is written in Robot Framework syntax.
5
6"""
7*** Settings ***
8Library    Collections
9Library    RequestsLibrary
10
11*** Test Cases ***
12Quick Get Request Test
13    ${response}=    GET  https://www.google.com
14    Should Be Equal As Strings    ${response.status_code}    200
15
16Quick Get Request With Parameters Test
17    ${params}=    Create Dictionary    query=robotframework    another=parameter
18    ${response}=    GET  https://www.google.com/search  params=${params}
19    Should Be Equal As Strings    ${response.status_code}    200
20
21Quick Get Request with Session Test
22    Create Session    google  https://www.google.com
23    ${response}=    GET On Session    google  /search  params=query=robotframework
24    Should Be Equal As Strings    ${response.status_code}    200
25"""