Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learning selenium
#1
In the code below :
from selenium import webdriver
import time

driver = webdriver.Chrome("C:\Users\Miécio\PycharmProjects\Selenium\drivers\chromedriver.exe")
driver.set_page_load_timeout("10")
driver.get("http://google.com.br")
driver.find_element_by_name("q").send_keys("Automação passo a passo")
driver.find_element_by_name("btnK").click()
time.sleep(4)
driver.quit()
generates the error:
Error:
C:\Users\Miécio\PycharmProjects\Selenium\venv\Scripts\python.exe C:/Users/Miécio/PycharmProjects/Selenium/Estudos/01.py File "C:/Users/Miécio/PycharmProjects/Selenium/Estudos/01.py", line 4 driver = webdriver.Chrome("C:\Users\Miécio\PycharmProjects\Selenium\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
How to fix?
Thanks :)
Reply
#2
Don't use backslash in paths on windows. '\U' is one of the escape sequences (there are others).
Use either raw string or forward slash.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,632 Nov-03-2017, 08:41 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020