-1

I am Trying to run a selenium script but it is not able to detect the chromedriver can anyone please help me on this when i try to run it it gives me an error stating that chromedriver is not present in the specific path however i have downloaded and kept it on the specific path below is the snap and code for reference. enter image description here

booking.py

import booking.constants as const
from selenium import webdriver


class Booking(webdriver.Chrome):
    def __init__(self , driver_path = "C:\\chromedriver.exe"):
        self.driver_path = driver_path
        super(Booking, self).__init__()

    
    def land_first_page(self):
        self.get(const.BASE_URL)

run.py //running this pythonfile in my editor

from booking.booking import Booking

inst = Booking()
inst.land_first_page()
Anshul Thakur
  • 69
  • 1
  • 6
  • Maybe try moving the chromedriver.exe to the Desktop and write the exact path "C:\Users\Desktop\chromedriver.exe". – Maximilian Freitag Oct 31 '21 at 19:05
  • getting a new error File "c:\Users\Anshul Thakur\Desktop\Selenium Python\Bot\booking\booking.py", line 6 def __init__(self , driver_path = "C:\Users\Desktop\chromedriver.exe"): ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape PS C:\Users\Anshul Thakur\Desktop\Selenium Python\Bot> – Anshul Thakur Oct 31 '21 at 19:11

3 Answers3

1

Try to insert the whole direction path of where the chromedriver is located, also don't forget to use double slash, "C:\Users\desktop\..." the whole path.

EDIT go and look for the version you are using of google chrome, then check the version of your chromedriver, if they are not the same that's the error, try to install the same chromedriver version of your google chrome version

Bernardo Olisan
  • 665
  • 7
  • 20
1

Copy Chromedriver.exe file and Paste your CODE directory

Then

import booking.constants as const
from selenium import webdriver

class Booking(webdriver.Chrome):
    def __init__(self , driver_path = "chromedriver.exe"):
        self.driver_path = driver_path
        super(Booking, self).__init__()


def land_first_page(self):
    self.get(const.BASE_URL

Looks Like. chromedriver.exe file must be same directory where your script file present

Kayes Fahim
  • 672
  • 5
  • 16
0

Copy your chromedriver.exe file to a folder in your current path, to display your current path you can use:

import sys
print(sys.path)

Be sure to use the same chromedriver's version as your browser

https://chromedriver.chromium.org/downloads

Augusto Sisa
  • 548
  • 4
  • 15