Skip to content

Commit

Permalink
update edge doc (#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaahong authored Feb 3, 2025
1 parent 0c704ac commit b40a1f8
Showing 1 changed file with 80 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ description: >-
这些是特定于微软Edge浏览器的功能和特性.
---

微软Edge是用Chromium实现的最早支持版本是v79.
微软Edge是用Chromium实现的, 最早支持版本是v79.
与Chrome类似, Edge驱动的主版本号必须与Edge浏览器的主要版本匹配.

[Chrome 页面]({{< ref "chrome.md" >}}) 上找到的所有capabilities和选项也适用于Edge.

## 选项

Capabilities common to all browsers are described on the [Options page]({{< ref "../drivers/options.md" >}}).
所有浏览器的共有功能在 [Options 页面]({{< ref "../drivers/options.md" >}}).

Capabilities unique to Chromium are documented at Google's page for
Chromium独有的功能记录在谷歌的
[Capabilities & ChromeOptions](https://chromedriver.chromium.org/capabilities)

使用基本定义的选项启动 Edge 会话如下所示:
Expand All @@ -41,16 +41,16 @@ Capabilities unique to Chromium are documented at Google's page for
{{< /tab >}}
{{< /tabpane >}}

### Arguments
### 参数

The `args` parameter is for a list of command line switches to be used when starting the browser.
There are two excellent resources for investigating these arguments:
`args` 参数用于列出启动浏览器时使用的命令行开关.
有两个很好的资源可用于研究这些参数:
* [Chrome Flags for Tooling](https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md)
* [List of Chromium Command Line Switches](https://peter.sh/experiments/chromium-command-line-switches/)

Commonly used args include `--start-maximized` and `--headless=new` and `--user-data-dir=...`
常用参数包括 `--start-maximized` `--headless=new` `--user-data-dir=...`

Add an argument to options:
为options添加参数:

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -73,12 +73,12 @@ Add an argument to options:
{{< /tab >}}
{{< /tabpane >}}

### Start browser in a specified location
### 在指定位置启动浏览器

The `binary` parameter takes the path of an alternate location of browser to use. With this parameter you can
use chromedriver to drive various Chromium based browsers.
`binary` 参数包含要使用的浏览器备用位置的路径.
使用此参数, 您可以使用 chromedriver 驱动各种基于 Chromium 的浏览器.

Add a browser location to options:
在options中添加浏览器位置:

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -101,13 +101,15 @@ Add a browser location to options:
{{< /tab >}}
{{< /tabpane >}}

### Add extensions
### 添加扩展

The `extensions` parameter accepts crx files. As for unpacked directories,
please use the `load-extension` argument instead, as mentioned in
[this post](https://chromedriver.chromium.org/extensions).

Add an extension to options:
`extensions`参数接受 crx 文件.
至于已解压的目录、中提到,
请使用[本文](https://chromedriver.chromium.org/extensions)中提及的 `load-extension`.


在options中添加扩展:

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -130,10 +132,11 @@ Add an extension to options:
{{< /tab >}}
{{< /tabpane >}}

### Keeping browser open
### 保持浏览器打开

Setting the `detach` parameter to true will keep the browser open after the process has ended,
so long as the quit command is not sent to the driver.
`detach` 参数设置为 true后,
只要不向driver发送退出命令,
就可以在进程结束后保持浏览器打开.

{{< tabpane text=true >}}
{{% tab header="Java" %}}
Expand All @@ -156,15 +159,15 @@ so long as the quit command is not sent to the driver.
{{< /tab >}}
{{< /tabpane >}}

### Excluding arguments
### 排除参数

MSEdgedriver has several default arguments it uses to start the browser.
If you do not want those arguments added, pass them into `excludeSwitches`.
A common example is to turn the popup blocker back on. A full list of default arguments
can be parsed from the
MSEdgedriver 有几个用于启动浏览器的默认参数.
如果不希望添加这些参数, 可将它们传递到 `excludeSwitches`.
一个常见的例子就是重新打开弹出窗口拦截器.
默认参数的完整列表参考
[Chromium Source Code](https://source.chromium.org/chromium/chromium/src/+/main:chrome/test/chromedriver/chrome_launcher.cc)

Set excluded arguments on options:
在options中设置排除参数:

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -188,25 +191,26 @@ Set excluded arguments on options:
{{< /tabpane >}}


## Service
## 服务

Examples for creating a default Service object, and for setting driver location and port
can be found on the [Driver Service]({{< ref "../drivers/service.md" >}}) page.
创建默认服务对象, 设置驱动程序位置和端口的示例可以参考
[Driver服务]({{< ref "../drivers/service.md" >}}) 页面.

### Log output
### 日志输出

Getting driver logs can be helpful for debugging issues. The Service class lets you
direct where the logs will go. Logging output is ignored unless the user directs it somewhere.
获取驱动程序日志有助于调试问题。
服务类可让您配置日志的输出。
日志输出会被忽略, 除非用户显示指定.

#### File output
#### 文件输出

To change the logging output to save to a specific file:
更改日志输出以保存到特定文件:

{{< tabpane text=true >}}
{{% tab header="Java" %}}
{{< badge-version version="4.10" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L101" >}}
**Note**: Java also allows setting file output by System Property:\
**注意**: Java同样允许在系统属性中配置文件输出:\
Property key: `EdgeDriverService.EDGE_DRIVER_LOG_PROPERTY`\
Property value: String representing path to log file
{{% /tab %}}
Expand All @@ -228,17 +232,17 @@ Property value: String representing path to log file
{{< /tab >}}
{{< /tabpane >}}

#### Console output
#### 控制台输出

To change the logging output to display in the console as STDOUT:
要更改日志输出, 使其在控制台中显示为标准输出:

{{< tabpane text=true >}}
{{% tab header="Java" %}}
{{< badge-version version="4.10" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L114" >}}
**Note**: Java also allows setting console output by System Property;\
Property key: `EdgeDriverService.EDGE_DRIVER_LOG_PROPERTY`\
Property value: `DriverService.LOG_STDOUT` or `DriverService.LOG_STDERR`
**注意**: Java同样允许在系统属性中配置控制台输出:\
属性键: `EdgeDriverService.EDGE_DRIVER_LOG_PROPERTY`\
属性值: `DriverService.LOG_STDOUT` `DriverService.LOG_STDERR`
{{% /tab %}}
{{< tab header="Python" >}}
{{< badge-version version="4.11" >}}
Expand All @@ -260,18 +264,19 @@ Property value: `DriverService.LOG_STDOUT` or `DriverService.LOG_STDERR`
{{< /tab >}}
{{< /tabpane >}}

### Log level
There are 6 available log levels: `ALL`, `DEBUG`, `INFO`, `WARNING`, `SEVERE`, and `OFF`.
Note that `--verbose` is equivalent to `--log-level=ALL` and `--silent` is equivalent to `--log-level=OFF`,
so this example is just setting the log level generically:
### 日志级别

有 6 种可用的日志级别: `ALL`, `DEBUG`, `INFO`, `WARNING`, `SEVERE`, 以及 `OFF`.
请注意, `--verbose` 等同于 `--log-level=ALL` , 而 `--silent` 等同于 `--log-level=OFF`,
因此, 本例只是一般性地设置日志级别:

{{< tabpane text=true >}}
{{% tab header="Java" %}}
{{< badge-version version="4.8" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L127-L128" >}}
**Note**: Java also allows setting log level by System Property:\
Property key: `EdgeDriverService.EDGE_DRIVER_LOG_LEVEL_PROPERTY`\
Property value: String representation of `ChromiumDriverLogLevel` enum
**注意**: Java同样允许在系统属性中配置日志级别:\
属性键: `EdgeDriverService.EDGE_DRIVER_LOG_LEVEL_PROPERTY`\
属性值: String representation of `ChromiumDriverLogLevel` enum
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_edge.py#L93" >}}
Expand All @@ -291,21 +296,21 @@ Property value: String representation of `ChromiumDriverLogLevel` enum
{{< /tab >}}
{{< /tabpane >}}

### Log file features
There are 2 features that are only available when logging to a file:
* append log
* readable timestamps
### 日志文件功能
有 2 项功能只有在记录到文件时才可用:
* 追加日志
* 可读时间戳

To use them, you need to also explicitly specify the log path and log level.
The log output will be managed by the driver, not the process, so minor differences may be seen.
要使用它们, 还需要明确指定日志路径和日志级别.
日志输出将由driver而非进程管理, 因此可能会出现细微差别.

{{< tabpane text=true >}}
{{% tab header="Java" %}}
{{< badge-version version="4.8" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L143-L144" >}}
**Note**: Java also allows toggling these features by System Property:\
Property keys: `EdgeDriverService.EDGE_DRIVER_APPEND_LOG_PROPERTY` and `EdgeDriverService.EDGE_DRIVER_READABLE_TIMESTAMP`\
Property value: `"true"` or `"false"`
**注意**: Java同样允许在系统属性中配置开闭这些功能:\
属性键: `EdgeDriverService.EDGE_DRIVER_APPEND_LOG_PROPERTY` 以及 `EdgeDriverService.EDGE_DRIVER_READABLE_TIMESTAMP`\
属性值: `"true"` `"false"`
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_edge.py#L104" >}}
Expand All @@ -325,19 +330,20 @@ Property value: `"true"` or `"false"`
{{< /tab >}}
{{< /tabpane >}}

### Disabling build check
### 禁用构建检查

Edge browser and msedgedriver versions should match, and if they don't the driver will error.
If you disable the build check, you can force the driver to be used with any version of Edge.
Note that this is an unsupported feature, and bugs will not be investigated.
Edge 浏览器和 msedgedriver 版本应该匹配,
如果不匹配, 驱动程序就会出错.
如果禁用构建检查, 则可以强制驱动程序与任何版本的 Edge 一起使用.
请注意, 这是一项不受支持的功能, 而且不会对错误进行调查.

{{< tabpane text=true >}}
{{% tab header="Java" %}}
{{< badge-version version="4.8" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L161-L162" >}}
**Note**: Java also allows disabling build checks by System Property:\
Property key: `EdgeDriverService.EDGE_DRIVER_DISABLE_BUILD_CHECK`\
Property value: `"true"` or `"false"`
**注意**: Java同样允许在系统属性中配置禁用构建检查:\
属性键: `EdgeDriverService.EDGE_DRIVER_DISABLE_BUILD_CHECK`\
属性值: `"true"` `"false"`
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_edge.py#L115" >}}
Expand All @@ -360,17 +366,17 @@ Property value: `"true"` or `"false"`

## Internet Explorer 兼容模式

微软Edge可以被"Internet Explorer兼容模式"驱动,
微软Edge可以被"Internet Explorer兼容模式"驱动,
该模式使用Internet Explorer驱动类与微软Edge结合使用.
阅读 [Internet Explorer 页面]({{< ref "internet_explorer.md" >}}) 了解更多详情.


## Special Features
Some browsers have implemented additional features that are unique to them.
## 特殊功能
某些浏览器实现了其特有的附加功能.

### Casting
### Cast

You can drive Chrome Cast devices with Edge, including sharing tabs
您可以使用 Edge 驱动 Chrome Cast 设备, 包括共享标签页

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -393,9 +399,9 @@ You can drive Chrome Cast devices with Edge, including sharing tabs
{{< /tab >}}
{{< /tabpane >}}

### Network conditions
### 网络状况

You can simulate various network conditions.
您可以模拟各种网络状况.

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -418,7 +424,7 @@ You can simulate various network conditions.
{{< /tab >}}
{{< /tabpane >}}

### Logs
### 日志

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -441,7 +447,7 @@ You can simulate various network conditions.
{{< /tab >}}
{{< /tabpane >}}

### Permissions
### 权限

{{< tabpane text=true >}}
{{< tab header="Java" >}}
Expand All @@ -464,6 +470,6 @@ You can simulate various network conditions.
{{< /tab >}}
{{< /tabpane >}}

### DevTools
### 开发者工具

See the [Chrome DevTools] section for more information about using DevTools in Edge
有关在 Edge 中使用 DevTools 的更多信息, 请参阅 [Chrome DevTools] 部分.

0 comments on commit b40a1f8

Please sign in to comment.