0

I can't able to run the selenium python code in pycharm and i can't able to open the chrome

My code is

from selenium import webdriver
driver = webdriver.Chrome("C:\Users\MNM\Desktop\drivers\chromedriver.exe")
driver.get("google.com")

The error message is

line 2

driver = webdriver.Chrome("C:\Users\MNM\Desktop\drivers\chromedriver.exe")
                         ^

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Process finished with exit code 1

1 Answer 1

3

If you look at the compilation error message you will see PEP 8: invalid escape sequence '\c'

You can use double \ to escape string

webdriver.Chrome("C:\\Users\\MNM\\Desktop\\drivers\\chromedriver.exe")

Or use r before the string to indicate it's string literal

webdriver.Chrome(r"C:\Users\MNM\Desktop\drivers\chromedriver.exe")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.