webdriver.ChromiumEdge(options=options)和webdriver.Edge(options=options)
时间: 2024-06-14 12:08:43 浏览: 7
`webdriver.ChromiumEdge(options=options)`和`webdriver.Edge(options=options)`都使用Selenium库中的`webdriver`模块创建Chromium Edge浏览器实例的方法,只是在调用时的函数名不同。
`webdriver.ChromiumEdge(options=options)`是使用Chromium Edge浏览器的方法,需要导入`msedge.selenium_tools`模块中的`Edge`和`EdgeOptions`类。在创建浏览器实例时,需要设置`options.use_chromium = True`来指定使用Chromium内核,然后通过`options.binary_location`设置浏览器的位置,最后使用`Edge(options=options)`创建浏览器实例。
范例代码如下[^1]:
```python
from selenium import webdriver
from msedge.selenium_tools import Edge, EdgeOptions
options = EdgeOptions()
options.use_chromium = True
options.binary_location = r"C:\xx\Microsoft\EdgeCore\93.0.926.0\msedge.exe"
driver = Edge(options=options, executable_path=r"D:\xx\Desktop\edgedriver_win64\msedgedriver.exe")
```
`webdriver.Edge(options=options)`是使用Edge浏览器的方法,不需要导入`msedge.selenium_tools`模块。在创建浏览器实例时,只需要设置`options.binary_location`来指定浏览器的位置,然后使用`webdriver.Edge()`创建浏览器实例。
范例代码如下:
```python
from selenium import webdriver
options = webdriver.EdgeOptions()
options.binary_location = r"C:\xx\Microsoft\EdgeCore\93.0.926.0\msedge.exe"
driver = webdriver.Edge(options=options)
```
相关推荐
![nupkg](https://img-home.csdnimg.cn/images/20210720083646.png)
![json](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)