Home > Software design >  How to write correct executable_path of selenium webdriver
How to write correct executable_path of selenium webdriver

Time:10-20

I am using selenium with python and tried to run chromedriver in my Windows PC. I unpacked the zip file to several folder, listed in PATH. However, the same error always appers: "'./chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home". I`ve tried to put chromedriver.exe in several folders, listed in PATH, include system32 and Windows, but no luck. Here is an example.

driver = webdriver.Chrome(executable_path = r'C:\\Users\\polikarpov\\AppData\\Local\\Microsoft\\WindowsApp\\chromedriver.exe')

CodePudding user response:

You can try this

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

driverpath = Service('C:\\Users\\polikarpov\\AppData\\Local\\Microsoft\\WindowsApp\\chromedriver.exe') #add your own path
driver = webdriver.Chrome(service=driverpath)

EXTRA TIP

If you want to run it in headless mode

option = webdriver.ChromeOptions()
option.add_argument('headless')
driver = webdriver.Chrome(service=driverpath, options=option)

CodePudding user response:

Try this:

driver = webdriver.Chrome(executable_path = r"C:\Users\polikarpov\AppData\Local\Microsoft\WindowsApp\chromedriver.exe")
  • Related