Skip to content

Update Chinese translation of "chrome_devtools" and "bidirectional" #885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update Chinese translation of "chrome_devtools" and "bidirectional"
  • Loading branch information
alaahong committed Dec 18, 2021
commit 704589b2abf3a37f56b48d58951b8e1f748f1759
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
---
title: "双向功能"
linkTitle: "双向"
title: "双向协议"
linkTitle: "双向协议"
weight: 16
aliases: [
"/documentation/zh-cn/webdriver/bidi_apis/",
"/zh-cn/documentation/webdriver/bidi_apis/"
]
---

Selenium is working with browser vendors to create the
[WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/)
as a means to provide a stable, cross-browser API that uses the bidirectional
functionality useful for both browser automation generally and testing specifically.
Before now, users seeking this functionality have had to rely on
with all of its frustrations and limitations.
Selenium正在与浏览器供应商合作创建
[WebDriver双向协议](https://w3c.github.io/webdriver-bidi/) ,
作为一种提供稳定的跨浏览器API的方法,
该API使用双向协议处理
各种浏览器的通用自动化以及特定测试的需求.
在此之前, 寻求此功能的用户
必须忍受当前实现的全部问题和局限.

The traditional webdriver model of strict request/response commands will be supplemented
with the ability to stream events from the user agent to the controlling software via WebSockets,
better matching the evented nature of the browser DOM.

Because it's a bad idea to tie your tests to a specific version of a specific browser,
the Selenium project recommends using WebDriver BiDi wherever possible.
However, until the spec is complete there are many useful things that the CDP offers.
To help keep your tests independent and portable, Selenium offers some useful helper classes.
At the moment, these use the CDP, but when we shall be using WebDriver Bidi as soon as possible
严格限制请求响应命令的传统webdriver模型,
将从user agent转变为基于WebScokets的软件控制,
通过这样完善流事件的能力,
以便更好地匹配浏览器DOM的事件性质.

因为将测试受限于特定浏览器的特定版本是个坏主意,
Selenium项目建议尽可能使用WebDriver BiDi.
然而, 在规范完成之前, CDP提供了许多有用的东西.
为了帮助保持测试的独立性和可移植性,
Selenium提供了一些有用的辅助类.
目前, 这些应用程序使用CDP,
但我们将尽快提供WebDriver Bidi的实现.
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,36 @@ aliases: [

{{% pageinfo color="warning" %}}
<p class="lead">
<i class="fas fa-language display-4"></i>
Page being translated from English to Chinese.
Do you speak Chinese? Help us to translate
it by sending us pull requests!
虽然Selenium 4提供了对Chrome DevTools Protocol (CDP) 的直接访问,
但是仍非常鼓励您使用
[WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}
代替.
</p>
{{% /pageinfo %}}

{{% pageinfo color="warning" %}}
<p class="lead">
While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), it is
highly encouraged that you use the
[WebDriver Bidi APIs]({{< ref "bidi_api.md" >}} instead.
</p>
{{% /pageinfo %}}

Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that
developers can use to debug web apps and explore the performance of their pages. Google Chrome's
DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short).
As the name suggests, this is not designed for testing, nor to have a stable API, so functionality
is highly dependent on the version of the browser.

WebDriver Bidi is the next generation of the W3C WebDriver protocol and aims to provide a stable API
implemented by all browsers, but it's not yet complete. Until it is, Selenium provides access to
the CDP for those browsers that implement it (such as Google Chrome, or Microsoft Edge, and
Firefox), allowing you to enhance your tests in interesting ways. Some examples of what you can
do with it are given below.

## Emulate Geo Location

Some applications have different features and functionalities across different
locations. Automating such applications is difficult because it is hard to emulate
the geo-locations in the browser using Selenium. But with the help of Devtools,
we can easily emulate them. Below code snippet demonstrates that.
许多浏览器都提供"开发工具" -- 一组与浏览器集成的工具,
开发人员可以用其调试web应用程序并探索其页面的性能.
谷歌浏览器开发工具
使用一种称为Chrome DevTools Protocol (简称"CDP") 的协议.
顾名思义, 这不是为测试而设计的,
而并没有一个稳定的API,
所以它的功能高度依赖于浏览器的版本.

WebDriver Bidi是W3C WebDriver的下一代协议,
旨在提供由所有浏览器实现稳定的API, 但尚未完成.
在此之前, Selenium提供了通过CDP实现的方式
(诸如Google Chrome或Microsoft Edge, 以及Firefox),
允许您以有趣的方式增强测试.
下面给出了实际使用的例子.

## 模拟地理位置

一些应用程序在不同的位置具有不同的特性和功能.
自动化此类应用程序很难,
因为很难使用Selenium在浏览器中模拟地理位置.
但是在Devtools的帮助下,
我们可以轻易模拟他们.
下面的代码片段演示了这一点.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -159,7 +156,7 @@ fun main() {
{{< /tab >}}
{{< /tabpane >}}

## Emulate Geo Location with the Remote WebDriver:
## 通过远程WebDriver模拟地理位置

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -316,12 +313,14 @@ fun main() {
{{< /tab >}}
{{< /tabpane >}}

## Override Device Mode
## 覆盖设备模式

Using Selenium's integration with CDP, one can override the current device
mode and simulate a new mode. Width, height, mobile, and deviceScaleFactor
are required parameters. Optional parameters include scale, screenWidth,
screenHeight, positionX, positionY, dontSetVisible, screenOrientation, viewport, and displayFeature.
使用Selenium与CDP的集成,
可以覆盖当前设备模式并模拟新模式.
Width, height, mobile和deviceScaleFactor是必需的参数.
可选参数包括scale, screenWidth,
screenHeight, positionX, positionY,
dontSetVisible, screenOrientation, viewport和displayFeature.

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
Expand Down