Bird
0
0

Which of the following is the correct syntax to add a cookie named token with value abc123 in Selenium Python?

easy📝 Syntax Q3 of 15
Selenium Python - Advanced Patterns
Which of the following is the correct syntax to add a cookie named token with value abc123 in Selenium Python?
Adriver.add_cookie({'name': 'token', 'value': 'abc123'})
Bdriver.addCookie('token', 'abc123')
Cdriver.add_cookie('token', 'abc123')
Ddriver.add_cookie(name='token', value='abc123')
Step-by-Step Solution
Solution:
  1. Step 1: Recall the add_cookie method signature

    The add_cookie method expects a single dictionary argument with keys 'name' and 'value'.
  2. Step 2: Check each option's syntax

    driver.add_cookie({'name': 'token', 'value': 'abc123'}) correctly passes a dictionary with 'name' and 'value'. Options A, B, and D use incorrect method signatures.
  3. Final Answer:

    driver.add_cookie({'name': 'token', 'value': 'abc123'}) -> Option A
  4. Quick Check:

    Add cookie syntax = add_cookie({'name':..., 'value':...}) [OK]
Quick Trick: add_cookie() needs a dict with 'name' and 'value' keys [OK]
Common Mistakes:
  • Passing name and value as separate arguments
  • Using camelCase method names
  • Using keyword arguments instead of dict

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes