[英]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.