Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

Error in python selenium 3 Edge web driver

I am a complete beginner to selenium and I wrote my first program just to connect to Google.

from selenium import webdriver
path = "C:\Users\Home\Documents\Python37-32\Scripts\Code\msedgedriver.exe"

driver = webdriver.Edge(path)

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

print(driver.title)"

My web driver version is 88.0.705.50 (Official build) (64-bit)

I use selenium 3 and I am getting this error while running the code. Also it is opening "data:," for a few seconds then opening Google. Lastly the browser doesn't stay open.

question from:https://stackoverflow.com/questions/65869107/error-in-python-selenium-3-edge-web-driver

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • Declare path on a separate line from the import statement

  • Use raw string in path or double escapes

Code:

from selenium import webdriver
path = r"C:UsersHomeDocumentsPython37-32ScriptsCodemsedgedriver.exe"

driver = webdriver.Edge(path)
driver.get("https://google.com")
print(driver.title)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...