我已經嘗試打開我的默認 chrome 瀏覽器超過 1 個月了。我現在還沒有成功。我已經發了另外 2 個沒有太大幫助的帖子。因此,我只嘗試最后一次,并希望最好。
我正在嘗試的是我想用 selenium 打開我的主 chrome 瀏覽器。我想這樣做的原因是使用某些 cookie 并從我的主瀏覽器登錄。我能看到自己得到它的唯一方法是打開我每天使用的 chrome 瀏覽器。
一段時間以來一直在撰寫一些代碼,并且仍然希望能夠在我的主瀏覽器中使用它。
我的代碼如下所示:
import time
from selenium import webdriver
import getpass
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\rober\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
driver = webdriver.Chrome(executable_path=r'C:\Users\rober\Desktop\Bot\chromedriver.exe', chrome_options=options)
driver.get("https://www.zalando.dk/jordan-air-jordan-1-mid-sneakers-high-joc12n001-a18.html")
buyButton = False
while buyButton is False:
try:
addToCartBtn = addButton = driver.find_element_by_xpath('/html/body/div[4]/div/div[2]/div/div/div[2]/div[1]/x-wrapper-re-1-6/div/div[4]/button')
print("Varen er udsolgt")
time.sleep(1)
driver.refresh()
except:
addToCartBtn = addButton = driver.find_element_by_xpath('//*[@id="picker-trigger"]')
print("Varen er p? Lager")
buyButton = True
while buyButton is True:
time.sleep(1)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.uc-btn#uc-btn-accept-banner"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='V?lg st?rrelse']"))).click()
driver.execute_script("return arguments[0].scrollIntoView(true);", WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//label[starts-with(@for, 'size-picker')]//span[text()='51.5']"))))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//label[starts-with(@for, 'size-picker')]//span[text()='51.5']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='L?g i indk?bskurv']"))).click()
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'a[title="Indk?bskurv"]'))).click()
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".z-coast-base__totals-tile .z-1-button__content"))).click()
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'a[title="Registrér dig"]'))).click()
我的錯誤如下所示:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 96
Current browser version is 99.0.4844.82 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
uj5u.com熱心網友回復:
此錯誤訊息...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 96
Current browser version is 99.0.4844.82 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
...暗示ChromeDriver無法啟動/產生新的瀏覽背景關系,即谷歌瀏覽器會議。
您的主要問題是您使用的二進制檔案版本之間的不兼容,如下所示:
- 您正在使用chrome=99.0
- 但是您使用的是chromedriver=96.0
- chromedriver=96.0的發行說明清楚地提到了以下內容:
支持 Chrome 版本 96
所以chromedriver=96.0和chrome=99.0之間存在明顯的不匹配
解決方案
確保這件事:
- ChromeDriver已更新到當前的ChromeDriver v99.0級別。
- Chrome 瀏覽器已更新為當前chrome=99.0(根據chromedriver=98.0.4758.48 發行說明)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/451807.html
標籤:Python 硒 谷歌浏览器 硒网络驱动程序 硒铬驱动程序
