Error Message: 'Chromedriver' Executable Needs to Be Path

Error message: 'chromedriver' executable needs to be available in the path

You can test if it actually is in the PATH, if you open a cmd and type in chromedriver (assuming your chromedriver executable is still named like this) and hit Enter. If Starting ChromeDriver 2.15.322448 is appearing, the PATH is set appropriately and there is something else going wrong.

Alternatively you can use a direct path to the chromedriver like this:

 driver = webdriver.Chrome('/path/to/chromedriver') 

So in your specific case:

 driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")

selenium - chromedriver executable needs to be in PATH

You can download ChromeDriver here:
https://sites.google.com/chromium.org/driver/

Then you have multiple options:

  • add it to your system path

  • put it in the same directory as your python script

  • specify the location directly via executable_path

     driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')

traceback: Message: 'chromedriver' executable needs to be in PATH

        os.environ['PATH'] += self.driver_path

This is not the right way to set the environment variable. Actually webdriver allows you to specific the path of chromedriver binary, so you don't need to make use of environment variable.

CHROMEDRIVER_PATH = r"C:\Users\Narsil\dev\seleniumDrivers\chromedriver.exe")

class Booking(webdriver.Chrome):

def __init__(self, driver_path=CHROMEDRIVER_PATH):
self.driver_path = driver_path
super(Booking, self).__init__(executable_path=driver_path)

Besides, IMO composition is more suitable than inheritance to build page object in most cases. Here is the sample.

class BasePageObject:
def __init__(self, driver_path):
self.driver = webdriver.Chrome(executable_path=driver_path)

class Booking(BasePageObject):
def land_page(self):
self.driver.get(const.BASE_URL)

Error chromedriver executable needs to be in PATH

In the self.driver = webdriver.Chrome(), pass the path to the executable as an argument in the parentheses.

For example:

self.driver = webdriver.Chrome('C:/user/Downloads/chromedriver.exe')



Related Topics



Leave a reply



Submit