Skip to content

Commit 87db007

Browse files
authored
Update Chinese translation of "interactions.zh-cn.md" and “elements\_index.zh-cn.md” (#929)[deploy site]
1 parent f573262 commit 87db007

File tree

2 files changed

+63
-58
lines changed

2 files changed

+63
-58
lines changed

website_and_docs/content/documentation/webdriver/elements/_index.zh-cn.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: "网络元素"
33
linkTitle: "元素"
44
weight: 8
5-
needsTranslation: true
65
aliases: [
76
"/documentation/zh-cn/webdriver/web_element/",
87
"/zh-cn/documentation/webdriver/web_element/"
@@ -11,4 +10,4 @@ description: >
1110
在DOM中识别和使用元素对象.
1211
---
1312

14-
The majority of most people's Selenium code involves working with web elements.
13+
大多数人的Selenium代码都涉及使用web元素.

website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,57 @@
11
---
2-
title: "Interacting with web elements"
3-
linkTitle: "Interactions"
2+
title: "Web元素交互"
3+
linkTitle: "交互"
44
weight: 2
55
description: >
6-
A high-level instruction set for manipulating form controls.
7-
needsTranslation: true
6+
用于操纵表单的高级指令集.
7+
88
---
99

10-
There are only 5 basic commands that can be executed on an element:
11-
* [click](https://w3c.github.io/webdriver/#element-click) (applies to any element)
12-
* [send keys](https://w3c.github.io/webdriver/#element-send-keys) (only applies to text fields and content editable elements)
13-
* [clear](https://w3c.github.io/webdriver/#element-send-keys) (only applies to text fields and content editable elements)
14-
* submit (only applies to form elements)
15-
* select (see [Select List Elements](select_lists.md))
16-
17-
## Additional validations
18-
19-
These methods are designed to closely emulate a user's experience, so,
20-
unlike the [Actions API]({{< ref "/documentation/webdriver/actions_api/" >}}), it attempts to perform two things
21-
before attempting the specified action.
22-
1. If it determines the element is outside the viewport, it
23-
[scrolls the element into view](https://w3c.github.io/webdriver/#dfn-scrolls-into-view), specifically
24-
it will align the bottom of the element with the bottom of the viewport.
25-
2. It ensures the element is [interactable](https://w3c.github.io/webdriver/#interactability)
26-
before taking the action. This could mean that the scrolling was unsuccessful, or that the
27-
element is not otherwise displayed. Determining if an element is displayed on a page was too difficult to
28-
[define directly in the webdriver specification](https://w3c.github.io/webdriver/#element-displayedness),
29-
so Selenium sends an execute command with a JavaScript atom that checks for things that would keep
30-
the element from being displayed. If it determines an element is not in the viewport, not displayed, not
31-
[keyboard-interactable](https://w3c.github.io/webdriver/#dfn-keyboard-interactable), or not
32-
[pointer-interactable](https://w3c.github.io/webdriver/#dfn-pointer-interactable),
33-
it returns an [element not interactable](https://w3c.github.io/webdriver/#dfn-element-not-interactable) error.
34-
35-
## Click
36-
37-
The [element click command](https://w3c.github.io/webdriver/#dfn-element-click) is executed on
38-
the [center of the element](https://w3c.github.io/webdriver/#dfn-center-point).
39-
If the center of the element is [obscured](https://w3c.github.io/webdriver/#dfn-obscuring) for some reason,
40-
Selenium will return an [element click intercepted](https://w3c.github.io/webdriver/#dfn-element-click-intercepted) error.
41-
42-
## Send keys
43-
44-
The [element send keys command](https://w3c.github.io/webdriver/#dfn-element-send-keys)
45-
types the provided keys into an [editable](https://w3c.github.io/webdriver/#dfn-editable) element.
46-
Typically, this means an element is an input element of a form with a `text` type or an element
47-
with a`content-editable` attribute. If it is not editable,
48-
[an invalid element state](https://w3c.github.io/webdriver/#dfn-invalid-element-state) error is returned.
49-
50-
[Here](https://www.w3.org/TR/webdriver/#keyboard-actions) is the list of
51-
possible keystrokes that WebDriver Supports.
10+
仅有五种基本命令可用于元素的操作:
11+
* [点击](https://w3c.github.io/webdriver/#element-click) (适用于任何元素)
12+
* [发送键位](https://w3c.github.io/webdriver/#element-send-keys) (仅适用于文本字段和内容可编辑元素)
13+
* [清除](https://w3c.github.io/webdriver/#element-send-keys) (仅适用于文本字段和内容可编辑元素)
14+
* 提交 (仅适用于表单元素)
15+
* 选择 (参见 [选择列表元素](select_lists.md))
16+
17+
## 附加验证
18+
19+
这些方法的设计目的是尽量模拟用户体验, 所以,
20+
[Actions接口]({{< ref "/documentation/webdriver/actions_api/" >}}) 不同,
21+
在指定制定操作之前,
22+
会尝试执行两件事.
23+
1. 如果它确定元素在视口之外,
24+
[则会将元素滚动到视图中](https://w3c.github.io/webdriver/#dfn-scrolls-into-view),
25+
特别是将元素底部与视口底部对齐.
26+
2. 确保元素在执行操作之前是[可交互的](https://w3c.github.io/webdriver/#interactability) .
27+
这可能意味着滚动不成功,
28+
或者该元素没有以其他方式显示.
29+
确定某个元素是否显示在页面上太难了
30+
[无法直接在webdriver规范中定义](https://w3c.github.io/webdriver/#element-displayedness),
31+
因此Selenium发送一个带有JavaScript原子的执行命令,
32+
检查是否有可能阻止该元素显示.
33+
如果确定某个元素不在视口中, 不显示, 不可
34+
[键盘交互](https://w3c.github.io/webdriver/#dfn-keyboard-interactable),
35+
或不可
36+
[指针交互](https://w3c.github.io/webdriver/#dfn-pointer-interactable),
37+
则返回一个[元素不可交互](https://w3c.github.io/webdriver/#dfn-element-not-interactable) 错误.
38+
39+
## 点击
40+
41+
[元素点击命令](https://w3c.github.io/webdriver/#dfn-element-click) 执行在 [元素中央](https://w3c.github.io/webdriver/#dfn-center-point).
42+
如果元素中央由于某些原因被 [遮挡](https://w3c.github.io/webdriver/#dfn-obscuring) ,
43+
Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#dfn-element-click-intercepted) 错误.
44+
45+
## 发送键位
46+
47+
[元素发送键位命令](https://w3c.github.io/webdriver/#dfn-element-send-keys)
48+
将录入提供的键位到 [可编辑的](https://w3c.github.io/webdriver/#dfn-editable) 元素.
49+
通常, 这意味着元素是具有 `文本` 类型的表单的输入元素或具有 `内容可编辑` 属性的元素.
50+
如果不可编辑, 则返回
51+
[无效元素状态](https://w3c.github.io/webdriver/#dfn-invalid-element-state) 错误.
52+
53+
[以下](https://www.w3.org/TR/webdriver/#keyboard-actions)
54+
是WebDriver支持的按键列表.
5255

5356
{{< tabpane >}}
5457
{{< tab header="Java" >}}
@@ -147,14 +150,15 @@ driver.quit()
147150
{{< /tab >}}
148151
{{< /tabpane >}}
149152

150-
## Clear
153+
## 清除
151154

152-
The [element clear command](https://w3c.github.io/webdriver/#dfn-element-clear) resets the content of an element.
153-
This requires an element to be [editable](https://w3c.github.io/webdriver/#dfn-editable),
154-
and [resettable](https://w3c.github.io/webdriver/#dfn-resettable-elements). Typically,
155-
this means an element is an input element of a form with a `text` type or an element
156-
with a`content-editable` attribute. If these conditions are not met,
157-
[an invalid element state](https://w3c.github.io/webdriver/#dfn-invalid-element-state) error is returned.
155+
[元素清除命令](https://w3c.github.io/webdriver/#dfn-element-clear)
156+
重置元素的内容.
157+
这要求元素 [可编辑](https://w3c.github.io/webdriver/#dfn-editable),
158+
[可重置](https://w3c.github.io/webdriver/#dfn-resettable-elements).
159+
通常, 这意味着元素是具有 `文本` 类型的表单的输入元素或具有 `内容可编辑` 属性的元素.
160+
如果不满足这些条件, 将返回
161+
[无效元素状态](https://w3c.github.io/webdriver/#dfn-invalid-element-state) 错误.
158162

159163
{{< tabpane langEqualsHeader=true >}}
160164
{{< tab header="Java" >}}
@@ -276,9 +280,11 @@ driver.quit()
276280
{{< /tab >}}
277281
{{< /tabpane >}}
278282

279-
## Submit
283+
## 提交
280284

281-
In Selenium 4 this is no longer implemented with a separate endpoint and functions by executing a script. As
282-
such, it is recommended not to use this method and to click the applicable form submission button instead.
285+
在Selenium 4中,
286+
不再通过单独的端点以及脚本执行的方法来实现.
287+
因此, 建议不要使用此方法,
288+
而是单击相应的表单提交按钮.
283289

284290

0 commit comments

Comments
 (0)