简体   繁体   English

python selenium 3 Edge web 驱动程序错误

[英]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.我是 selenium 的完整初学者,我编写了第一个程序只是为了连接到 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)我的 web 驱动程序版本是88.0.705.50 (Official build) (64-bit)

I use selenium 3 and I am getting this error while running the code.我使用 selenium 3 并且在运行代码时遇到此错误。 Also it is opening "data:," for a few seconds then opening Google.它还在打开"data:,"几秒钟,然后打开谷歌。 Lastly the browser doesn't stay open.最后,浏览器不会保持打开状态。

  • 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)

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.这是浏览器使用data:,打开的默认行为,然后它将定向到您想要的网站。 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:您可以参考以下步骤在 python selenium 中自动化 Edge:

  • Make sure the WebDriver version is the same as the Edge version.确保 WebDriver 版本与 Edge 版本相同。

  • Install the MS Edge Selenium tools using command below:使用以下命令安装 MS Edge Selenium 工具:

     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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python selenium web驱动程序错误 - Python selenium web driver error Python,网络驱动程序错误(Selenium) - Python, error with web driver (Selenium) Selenium Driver for Edge 获取恒定版本错误 - Selenium Driver for Edge getting constant version error web 使用 Selenium 和 Edge 使用 Python 刮擦时出现基本错误 - Basic Error while web scraping using Selenium and Edge with Python 带有 MS Edge 浏览器的 Python (Selenium):'Connection aborted.', ConnectionResetError(10054, ...)“Microsoft Web Driver 已停止工作” - Python (Selenium) with MS Edge browser: 'Connection aborted.', ConnectionResetError(10054, ...) "Microsoft Web Driver has stopped working" 用于Python中Selenium的Firefox Web驱动程序 - Firefox web driver for Selenium in Python 如何使用python修复Selenium Web驱动程序``异常错误'' - How to fix selenium web driver 'exception error' with python 使用 Selenium Web 驱动程序和 Python 获取所选选项时出错 - Error by getting selected option using Selenium Web Driver with Python 默认下载目录 Edge web 驱动 - python - Default download directory Edge web driver - python Python-Selenium Web驱动程序错误-self._driver.execute-AttributeError:“ unicode”对象没有属性“ id” - Python - Selenium Web Driver error - self._driver.execute - AttributeError: 'unicode' object has no attribute 'id'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM