from selenium.webdriver import Firefox driver = Firefox() driver.get("https://www.example.com") cookie = {'name': 'currency', 'value': 'USD'} driver.add_cookie(cookie) driver.refresh()
from selenium.webdriver import Firefox driver = Firefox() driver.get("https://www.example.com") cookies = [{'name': 'currency', 'value': 'USD'}, {'name': 'language', 'value': 'en'}] for cookie in cookies: driver.add_cookie(cookie) driver.refresh()This code example is similar to the previous one, but it demonstrates how to add multiple cookies at once. It creates a list of cookies and loops through it to add them to the Firefox browser session. Finally, it refreshes the web page to apply the new cookies.