0

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.

1
  • Well, it doesn't stay open bcs you didn't give him any more commands so it shuts down. To keep it open you can use time.sleep()
    – Leemosh
    CommentedJan 24, 2021 at 10:02

2 Answers 2

1
  • 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:\Users\Home\Documents\Python37-32\Scripts\Code\msedgedriver.exe" driver = webdriver.Edge(path) driver.get("https://google.com") print(driver.title) 
1
  • Thank you!! Will definitely try it outCommentedJan 25, 2021 at 11:08
0

What error do you get? It's the default behavior that the browser opens with data:,, then it will direct to the website you want. The browser doesn't stay opened may because the error breaks it.

You can refer to the following steps to automate Edge in python selenium:

  • Make sure the WebDriver version is the same as the Edge version.

  • Install the MS Edge Selenium tools using command below:

    pip install msedge-selenium-tools selenium==3.141 
  • Sample code:

    from msedge.selenium_tools import Edge, EdgeOptions options = EdgeOptions() options.use_chromium = True driver = Edge(executable_path = r"C:\Users\Home\Documents\Python37-32\Scripts\Code\msedgedriver.exe", options = options) driver.get("https://google.com") print(driver.title) 
2
  • Thank you so much I'm gonna try it out and get back to you guys.CommentedJan 25, 2021 at 11:08
  • Yeah i didnt quite test the code which you have posted because i shifted to another device just recently and installed the chrome driver instead of edge driver. And yes i will refer itCommentedJan 27, 2021 at 10:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.