I'm a beginner in Python and Selenium, and I dont know what is the error in my code or environment. How to solve this problem?
app.py:-
from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://github.com")
Error:-
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
Backtrace:
Ordinal0 [0x0025D953 2414931]
Ordinal0 [0x001EF5E1 1963489]
Ordinal0 [0x000DC6B8 837304]
Ordinal0 [0x000F7A8E 948878]
Ordinal0 [0x000F5FB1 942001]
Ordinal0 [0x00129100 1151232]
Ordinal0 [0x00128D5A 1150298]
Ordinal0 [0x001242B6 1131190]
Ordinal0 [0x000FE860 976992]
Ordinal0 [0x000FF756 980822]
GetHandleVerifier [0x004CCC62 2510274]
GetHandleVerifier [0x004BF760 2455744]
GetHandleVerifier [0x002EEABA 551962]
GetHandleVerifier [0x002ED916 547446]
Ordinal0 [0x001F5F3B 1990459]
Ordinal0 [0x001FA898 2009240]
Ordinal0 [0x001FA985 2009477]
Ordinal0 [0x00203AD1 2046673]
BaseThreadInitThunk [0x7631FA29 25]
RtlGetAppContainerNamedObjectPath [0x77877A7E 286]
RtlGetAppContainerNamedObjectPath [0x77877A4E 238]
(No symbol) [0x00000000]
CodePudding user response:
To initiate a Brave browser session additionally you have to pass the absolute location of the brave-browser binary through the binary_location argument of an instance of ChromeOptions.
from selenium import webdriver
driver_path = "C:/Users/username/PycharmProjects/chromedriver.exe"
brave_path = "C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"
option = webdriver.ChromeOptions()
option.binary_location = brave_path
# option.add_argument("--incognito") OPTIONAL
# option.add_argument("--headless") OPTIONAL
# Create new Instance of Chrome
browser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)
browser.get("https://www.google.es")
Note:- Add chromedriver to path to access it without typing Location.
For More Details, Have a look at this Link
How to use Brave web browser with python, selenium and chromedriver?
CodePudding user response:
- Pass chromedriver.exe path
chromedriver_path = C:\chromedriver\chromedriver.exe # this is example path you haveto pass your downloaded chromedriver path
driver = webdriver.Chrome(executable_path = "Enter your chromedriver path")
driver.get("https://github.com")
- You have to download chromedriver and put it in your python file's folder. Then you don't need to pass chromedriver path.
driver = webdriver.Chrome()
driver.get("https://github.com")