Recall & Review
beginner
What is a cookie in web testing?
A cookie is a small piece of data stored by the browser to remember information about the user or session. In testing, cookies help verify user sessions and preferences.
Click to reveal answer
beginner
How do you add a cookie using Selenium in Python?
Use the method
driver.add_cookie({'name': 'key', 'value': 'value'}) to add a cookie to the current browser session.Click to reveal answer
beginner
How can you delete all cookies in Selenium Python?
Call
driver.delete_all_cookies() to remove all cookies stored in the browser for the current domain.Click to reveal answer
intermediate
Why is cookie management important in automated testing?
Managing cookies helps simulate user sessions, test login states, and verify security features like session expiration.
Click to reveal answer
beginner
What does
driver.get_cookies() return in Selenium Python?It returns a list of dictionaries, each representing a cookie with details like name, value, domain, and expiry.
Click to reveal answer
Which Selenium Python method adds a cookie to the browser?
✗ Incorrect
The correct method to add a cookie is driver.add_cookie() with a dictionary argument.
What does driver.delete_all_cookies() do?
✗ Incorrect
It deletes all cookies stored for the current domain in the browser session.
Which data type does driver.get_cookies() return?
✗ Incorrect
driver.get_cookies() returns a list where each item is a dictionary representing a cookie.
Why might you want to delete cookies during a test?
✗ Incorrect
Deleting cookies helps simulate a fresh user session without previous data.
Which of these is NOT a typical cookie attribute in Selenium?
✗ Incorrect
Cookies do not have a 'color' attribute; common attributes include name, value, domain, path, and expiry.
Explain how to add, retrieve, and delete cookies in Selenium Python.
Think about the methods that start with 'add', 'get', and 'delete'.
You got /3 concepts.
Why is managing cookies important when automating web tests?
Consider what cookies store and how they affect user experience.
You got /3 concepts.