I am trying to learn web scraping with Python and Selenium. However, I have been getting an error of FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
and I am 100% sure that the file is located on the path that I specified as I tried it with much simpler approach before and everything was working fine.
This is my code right now;
class Booking(webdriver.Chrome):
def __init__(self, driver_path=r"/Users/username/Desktop/SeleniumDriver/chromedriver"):
self.driver_path = driver_path
os.environ["PATH"] += r"/Users/username/Desktop/SeleniumDriver"
super(Booking, self).__init__()
def land_first_page(self):
self.get("https://website.com")
inst = Booking()
inst.land_first_page()
I have tried different many paths with/without r as prefix as well as /chromedriver with exe as an extension or without. Nothing seems to be working. I am getting the error that I mentioned above when instantiating the Booking class
Instead of using OOP if I use the webdriver like this;
os.environ["PATH"] += r"/Users/username/Desktop/SeleniumDriver"
driver = webdriver.Chrome("/Users/username/Desktop/SeleniumDriver/chromedriver")
driver.get("https://website.com")
It works, and doesn't give me any errors, but I would prefer to use OOP approach as it much more clear for me to work with, especially when creating bots