Bird
0
0

Which of the following is the correct way to add a cookie named user with value admin in Selenium Python?

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

    The method add_cookie expects a dictionary with keys 'name' and 'value'.
  2. Step 2: Match the correct syntax

    driver.add_cookie({'name': 'user', 'value': 'admin'}) correctly uses driver.add_cookie({'name': 'user', 'value': 'admin'}).
  3. Final Answer:

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

    add_cookie needs dict with 'name' and 'value' keys = A [OK]
Quick Trick: Use a dict with 'name' and 'value' keys for add_cookie [OK]
Common Mistakes:
  • Using camelCase method names like addCookie
  • Passing cookie name and value as separate arguments
  • Passing a dict without 'name' and 'value' keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes