Selenium invalid argument: invalid ‘sameSite’

I am trying to login to the facebook with my cookie

My code

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options

from pyvirtualdisplay import Display

import time
import datetime
import re
import json

USER_AGENT = "https://www.facebook.com/profile.php?id=100065441650865:Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML%2C like Gecko) Mobile/15E148"

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--user-agent=%s' % USER_AGENT)

driver = webdriver.Chrome(chrome_options=chrome_options)
cook_raw = """[{"name":"datr","value":"9LxhYGI0ori9e12XN2gNvghz","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":true,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"fr","value":"1AA4osPKCX9nJGX7c.AWUXi6QDYFGgk4QoYxIHSh36ptM.BgYbz0.pZ.AAA.0.0.BgYb0y.AWUfR3NDQZo","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":true,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"xs","value":"15%3AU3H1Bw-UVoF8Zg%3A2%3A1617018175%3A-1%3A-1","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":true,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"m_pixel_ratio","value":"1","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":false,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"c_user","value":"100065441650865","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":false,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"sb","value":"9LxhYIx_hHCUfV4psw4KDoRB","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":true,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"wd","value":"1080x1920","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":false,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null},{"name":"x-referer","value":"eyJyIjoiL2VudGVyY29kZS5waHA%2FY3A9Y2hhbGRlZXYxazRuJTQwbWFpbC5ydSZzb3VyY2VfdmVyaWZpZWQ9bV9zZXR0aW5ncyZyZWRpcmVjdF90b191bmlmaWVkX2NvbnRhY3Rfc2V0dGluZ19wYWdlIiwiaCI6Ii9lbnRlcmNvZGUucGhwP2NwPWNoYWxkZWV2MWs0biU0MG1haWwucnUmc291cmNlX3ZlcmlmaWVkPW1fc2V0dGluZ3MmcmVkaXJlY3RfdG9fdW5pZmllZF9jb250YWN0X3NldHRpbmdfcGFnZSIsInMiOiJtIn0%3D","domain":".facebook.com","hostOnly":false,"path":"/","secure":true,"httpOnly":false,"sameSite":"no_restriction","session":true,"firstPartyDomain":"","storeId":null}]"""
cookie_dict = json.loads(cook_raw)
driver.get("https://www.facebook.com")
driver.add_cookie(cookie_dict[0])

I have an error

InvalidArgumentException: Message: invalid argument: invalid 'sameSite'

How can I fix the error?



Read more here: https://stackoverflow.com/questions/67374323/selenium-invalid-argument-invalid-samesite

Content Attribution

This content was originally published by swor at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: