0
0
Selenium Pythontesting~10 mins

Cookie management in Selenium Python - Interactive Code Practice

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

Complete the code to add a cookie named 'user' with value 'admin'.

Selenium Python
driver.add_cookie({"name": "user", "value": [1])
Drag options to blanks, or click blank then click option'
A"value"
B"user"
C"cookie"
D"admin"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the cookie name as the value.
Forgetting to put the value in quotes.
2fill in blank
medium

Complete the code to delete a cookie named 'session_id'.

Selenium Python
driver.delete_cookie([1])
Drag options to blanks, or click blank then click option'
A"user"
B"cookie"
C"session_id"
D"id"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong cookie name.
Not using quotes around the cookie name.
3fill in blank
hard

Fix the error in the code to get a cookie named 'token'.

Selenium Python
cookie = driver.get_cookie([1])
Drag options to blanks, or click blank then click option'
Acookie
B"token"
C'token'
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the cookie name without quotes.
Using a variable name instead of a string.
4fill in blank
hard

Fill both blanks to check if a cookie named 'auth' exists and print its value.

Selenium Python
cookie = driver.get_cookie([1])
if cookie is not [2]:
    print(cookie['value'])
Drag options to blanks, or click blank then click option'
A"auth"
BNone
CFalse
D"auth_cookie"
Attempts:
3 left
💡 Hint
Common Mistakes
Checking against False instead of None.
Using wrong cookie name or missing quotes.
5fill in blank
hard

Fill all three blanks to add a cookie with name 'theme', value 'dark', and path '/app'.

Selenium Python
driver.add_cookie({"name": [1], "value": [2], "path": [3])
Drag options to blanks, or click blank then click option'
A"theme"
B"dark"
C"/app"
D"/home"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong path or missing quotes.
Mixing up name and value.