0
0
Testing Fundamentalstesting~10 mins

API test automation concepts in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a GET request using the requests library.

Testing Fundamentals
response = requests.[1]('https://api.example.com/data')
Drag options to blanks, or click blank then click option'
Aget
Bpost
Cput
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' instead of 'get' for retrieving data.
2fill in blank
medium

Complete the code to check if the response status code is 200 (OK).

Testing Fundamentals
assert response.[1] == 200
Drag options to blanks, or click blank then click option'
Astatus_code
Btext
Cjson
Dheaders
Attempts:
3 left
💡 Hint
Common Mistakes
Checking response.text instead of response.status_code.
3fill in blank
hard

Fix the error in the code to parse JSON response correctly.

Testing Fundamentals
data = response.[1]()
Drag options to blanks, or click blank then click option'
Atext
Bcontent
Cjson
Dstatus_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using response.text instead of response.json() to parse JSON.
4fill in blank
hard

Fill both blanks to send a POST request with JSON payload and check status code.

Testing Fundamentals
response = requests.[1]('https://api.example.com/create', json=[2])
assert response.status_code == 201
Drag options to blanks, or click blank then click option'
Apost
B{'name': 'test'}
C{'id': 1}
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET method instead of POST.
Passing payload as string instead of dictionary.
5fill in blank
hard

Fill all three blanks to extract a value from JSON response and assert it equals expected.

Testing Fundamentals
data = response.[1]()
value = data.get('[2]')
assert value [3] 'success'
Drag options to blanks, or click blank then click option'
Ajson
Bstatus
C==
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using response.text instead of response.json().
Wrong key name in get().
Using assignment '=' instead of comparison '=='.