I've been watching a freecodecamp video about selenium I python and this method he uses doesn't work for me and I can't see why
class Booking(webdriver.Chrome):
def __init__(self, driver_path=r"C:\SeleniumDrivers"):
self.driver_path = driver_path
os.environ['PATH'] += self.driver_path
super(Booking, self).__init__()
def land_first_page(self):
self.get('https://www.booking.com')
I am not sure if you missed the code or was missed in the video - the path separator is missing in this code. so when joining the path, path separator need to be there(example --> : for mac and ; for windows) pls refer to the comments in the code.
from selenium import webdriver
import os
class Booking(webdriver.Chrome):
def __init__(self, driver_path=r"C:\SeleniumDrivers"):
self.driver_path = driver_path
os.environ['PATH'] += os.pathsep + self.driver_path # os.pathsep is missing,i.e add chromedriver path the system path.
super(Booking, self).__init__()
def land_first_page(self):
self.get('https://www.booking.com')
also ensure that chromedriver has been downloaded and copied to C:\\SeleniumDrivers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.