Home > database >  How to fix Selenium error SyntaxError and webdriver path location error
How to fix Selenium error SyntaxError and webdriver path location error

Time:04-26

I’m confused as to what is causing this error:

The chrome version is 100.0.4986 which is the latest Google chrome version

Python version is 3.9.1: Python version

Chrome web driver version is 100.0: Chrome webdriver version

Path and location of web driver Path and location of webdriver

Code below and error:

from selenium import webdriver

driver = webdriver.Chrome('C:\Users\sanas\OneDrive\CSIT 110 Python\chromedriver')

driver.get("https://www.google.com")

Error CMD error

CodePudding user response:

Backslash \ is an escape character, so you have to use \\ Change your code to:

driver = webdriver.Chrome('C:\\Users\\sanas\\OneDrive\\CSIT 110 Python\\chromedriver')

CodePudding user response:

Solution:

Use the \\ in window and provide the complete path, you forget to add .exe

driver = webdriver.Chrome('C:\\Users\\sanas\\OneDrive\\CSIT 110 Python\\chromedriver.exe')

CodePudding user response:

You can use one of following :

driver = webdriver.Chrome('C:\\Users\\sanas\\OneDrive\\CSIT\\Python\\chromedriver.exe'

Or

driver = webdriver.Chrome('C:/Users/sanas/OneDrive/CSIT/Python/chromedriver.exe'
  • Related