在运行代码时无法找到chrome二进制文件



我对python和selenium很陌生我正试图使一个脚本,检查如果一个元素(日期picker中的日期)是启用或禁用

我总是得到这个错误:selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

这是代码:


import datetime
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
driver_service = Service(executable_path=r"C:UsersAdminDesktopTestchromedriver.exe")
driver = webdriver.Chrome(service=driver_service)
options = webdriver.ChromeOptions()
options.binary_location = r"C:UsersAdminAppDataLocalGoogleChromeApplicationchrome.exe"

url = "URL"
browser = webdriver.Chrome(executable_path=r"C:UsersAdminDesktopTestchromedriver.exe")
browser.get(url)

def next_7_dates():
today = datetime.datetime.today()
date_list = []
for x in range(0,7):
new_date = today + datetime.timedelta(days=x)
date_list.append(new_date.strftime('%Y-%m-%d'))
return date_list

Available_date = browser.find_element_by_xpath("/html/body/div[1]/span/form/div/div[2]/div[8]")
Free = find_element_by_class_name("bg-disabled")
if Free.is_enabled():
print("No Appointments available")

我是新来的,我几乎在测试东西

你差一点就成功了。您只需要正确地提供参数,并按正确的顺序提供代码行,如下所示:

driver_service = Service(r"C:UsersAdminDesktopTestchromedriver.exe")
options = webdriver.ChromeOptions()
options.binary_location = r"C:UsersAdminAppDataLocalGoogleChromeApplicationchrome.exe"
driver = webdriver.Chrome(service=driver_service, , options=options)
url = "URL"
browser.get(url)

相关内容

  • 没有找到相关文章