Home > Software engineering >  Problem is selenium, python, beginner in coding
Problem is selenium, python, beginner in coding

Time:12-14

I received this error when trying to run my code, let me know what I can do. If needed I'll post the full code here.

Traceback (most recent call last):
  File "C:\Users\hp\Desktop\FB\GUI.py", line 104, in <module>
    main()
  File "C:\Users\hp\Desktop\FB\GUI.py", line 65, in main
    driver = webdriver.Chrome(options=options)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site- 
packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
 File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.19042 x86_64)    

CodePudding user response:

you need to install a chrome driver and tell selenium where to find it. by either:

  • updating your PATH
  • using executable_path when instantiating a new driver

then install chrome and tell chrome driver where to find it.

CodePudding user response:

The message indicate that the chrome driver was either not installed or not found by Python code.

Check the following link to setup chrome drivers:

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

The best way is to download the binary from following link:

https://sites.google.com/a/chromium.org/chromedriver/

Once done, you can identify the path to the driver present in the local directory like following:

from selenium import webdriver from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
  • Related