It’s like this. I want driver to add a set of cookies after accessing a webpage with slider verification,
but it failed. I can’t find the reason for it
somebody help me!!! pls! <3
error
code
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import os
def get(cookie:str,link:str):
cookie = {c.split("=")[0]:"=".join(c.split("=")[1:]) for c in cookie.split(";") if c}
chrome_options = Options()
chrome_options.binary_location = "D:/chrome_bot/chrome-win64/chrome.exe"
chrome_service = Service("D:/chrome_bot/chromedriver-win64/chromedriver.exe")
driver = webdriver.Chrome(service=chrome_service,options=chrome_options)
driver.get(link)
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
driver.delete_all_cookies()
for key,val in cookie.items():
driver.add_cookie({'name':key,'value':val})
driver.get(link)
os.system("pause")
I browsed a large number of examples and documents, and I downloaded chrome and chromedriver from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json and placed them in a fixed file directory. Then, when I called the add_cookie() function, an error occurred.
Lain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1