Issue
I am using selenium web driver for an assignment in Python. I am getting a syntax error. I am using google colab and Python 3.
Here is my code
import time
from selenium import webdriver
driver = webdriver.Chrome (r "C:\Users\Anisha\Downloads\chromedriver.exe")
time.sleep(20)
I am getting error
File "<ipython-input-28-7654fa692ce2>", line 1
driver = webdriver.Chrome (r "C:\Users\Anisha\Downloads\chromedriver.exe")
^
SyntaxError: invalid syntax
Please help I am not getting where I am wrong.
Solution
If you intend to pass the location of the chromedriver binary in Windows OS you have to:
- While mentioning the absolute location of the chromedriver binary through the Key / Value pair of executable_path you have to add the binary extension as as well i.e.
.exe
. - While mentioning the absolute location of the chromedriver binary you have to either use the single front slash i.e.
\
along with the rawr
switch or you have to escape the back slash\\
. Your effective line of code will be :
Either in this format:
driver = webdriver.Chrome(executable_path="C:\\Users\\Anisha\\Downloads\\chromedriver.exe")
Or in this format:
driver = webdriver.Chrome(executable_path=r'C:\Users\Anisha\Downloads\chromedriver.exe')
Answered By - undetected Selenium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.