I am so new to python and selenium I am trying to make a script that checks if an element (date in a datepicker) is enabled or disabled
I always get this error : selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
this is the code :
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:\Users\Admin\Desktop\Test\chromedriver.exe")
driver = webdriver.Chrome(service=driver_service)
options = webdriver.ChromeOptions()
options.binary_location = r"C:\Users\Admin\AppData\Local\Google\Chrome\Application\chrome.exe"
url = "URL"
browser = webdriver.Chrome(executable_path=r"C:\Users\Admin\Desktop\Test\chromedriver.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")
I am new to I am pretty much testing stuff
CodePudding user response:
You were almost there. You just need to supply the arguments properly and supply the lines of code in proper sequence as follows:
driver_service = Service(r"C:\Users\Admin\Desktop\Test\chromedriver.exe")
options = webdriver.ChromeOptions()
options.binary_location = r"C:\Users\Admin\AppData\Local\Google\Chrome\Application\chrome.exe"
driver = webdriver.Chrome(service=driver_service, , options=options)
url = "URL"
browser.get(url)