Rabbu
Rabbu

Reputation: 1

Unable to launch selenium with python in Mac OS SUR

/usr/local/bin/python3.9 /Users/rabbu/PycharmProjects/pythonProject/seleniumpkg/Basic.py
Traceback (most recent call last):
  File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../drivers.chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rabbu/PycharmProjects/pythonProject/seleniumpkg/Basic.py", line 4, in <module>
    driver = webdriver.Chrome(executable_path="../drivers.chromedriver")
  File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'drivers.chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Process finished with exit code 1

Upvotes: 0

Views: 360

Answers (1)

theNishant
theNishant

Reputation: 665

You can use webdriver_manager to directly download and launch the driver without providing the path.

You can install by using webdriver_manager by using pip3 install webdriver_manager

from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())

driver.get("Your URL")

Upvotes: 1

Related Questions