Bird
0
0

Find the issue in this code:

medium📝 Debug Q7 of 15
Selenium Python - Advanced Patterns
Find the issue in this code:
cookie = {'name': 'id', 'value': '123', 'expiry': '2025-01-01'}
driver.add_cookie(cookie)
A'expiry' value should be an integer timestamp, not a string
B'name' key must be 'Name' with capital N
Cadd_cookie does not accept 'expiry' key
DCookie dictionary must be a list, not dict
Step-by-Step Solution
Solution:
  1. Step 1: Check 'expiry' key format

    The 'expiry' key must be an integer representing Unix timestamp, not a date string.
  2. Step 2: Validate other keys and types

    'name' and 'value' keys are correct. The dictionary type is correct for add_cookie.
  3. Final Answer:

    'expiry' value should be an integer timestamp, not a string -> Option A
  4. Quick Check:

    Expiry must be int timestamp [OK]
Quick Trick: Expiry date must be Unix timestamp integer [OK]
Common Mistakes:
  • Using string dates for expiry
  • Capitalizing keys incorrectly
  • Passing cookie as list instead of dict

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes