|
1 | 1 | ---
|
2 |
| -title: "Page loading strategy" |
| 2 | +title: "页面加载策略" |
3 | 3 | weight: 8
|
4 | 4 | ---
|
5 | 5 |
|
6 |
| -Defines the current session's page loading strategy. |
7 |
| -By default, when Selenium WebDriver loads a page, |
8 |
| -it follows the _normal_ pageLoadStrategy. |
9 |
| -It is always recommended to stop downloading additional |
10 |
| -resources (like images, css, js) when the page loading takes lot of time. |
| 6 | +定义当前会话的页面加载策略. |
| 7 | +默认情况下, 当Selenium WebDriver加载页面时, |
| 8 | +遵循 _normal_ 的页面加载策略. |
| 9 | +始终建议您在页面加载缓慢时, |
| 10 | +停止下载其他资源 (例如图片, css, js) . |
11 | 11 |
|
12 |
| -The `document.readyState` property of a document describes the loading state of the current document. |
13 |
| -By default, WebDriver will hold off on responding to a `driver.get()` (or) `driver.navigate().to()` |
14 |
| -call until the document ready state is `complete` |
15 | 12 |
|
16 |
| -In SPA applications (like Angular, react, Ember) once the dynamic content |
17 |
| -is already loaded (I.e once the pageLoadStrategy status is COMPLETE), |
18 |
| -clicking on a link or performing some action within the page will not make a new request |
19 |
| -to the server as the content is dynamically loaded at the client side without a pull page refresh. |
| 13 | +`document.readyState` 属性描述当前页面的加载状态. |
| 14 | +默认情况下, 在页面就绪状态是 `complete` 之前, |
| 15 | +WebDriver都将延迟 `driver.get()` 的响应或 |
| 16 | + `driver.navigate().to()` 的调用. |
20 | 17 |
|
21 |
| -SPA applications can load many views dynamically |
22 |
| -without any server requests, So pageLoadStrategy |
23 |
| -will always show `COMPLETE` status until |
24 |
| -we do a new `driver.get()` and `driver.naviagte().to()` |
25 | 18 |
|
26 |
| -WebDriver _pageLoadStrategy_ supports the following values: |
| 19 | +在单页应用程序中 (例如Angular, react, Ember) , |
| 20 | +一旦动态内容加载完毕 (即pageLoadStrategy状态为COMPLETE) , |
| 21 | +则点击链接或在页面内执行某些操作的行为将不会向服务器发出新请求, |
| 22 | +因为内容在客户端动态加载, |
| 23 | +无需刷新页面. |
| 24 | + |
| 25 | + |
| 26 | +单页应用程序可以动态加载许多视图, |
| 27 | +而无需任何服务器请求, |
| 28 | +因此页面加载策略将始终显示为 `COMPLETE` 的状态, |
| 29 | +直到我们执行新的 `driver.get()` 或 `driver.naviagte().to()` 为止. |
| 30 | + |
| 31 | + |
| 32 | +WebDriver的 _页面加载策略_ 支持以下内容: |
27 | 33 |
|
28 | 34 | ## normal
|
29 | 35 |
|
30 |
| -This will make Selenium WebDriver to wait for the entire page is loaded. |
31 |
| -When set to **normal**, Selenium WebDriver waits until the |
32 |
| -[load](https://developer.mozilla.org/zh-CN/docs/Web/Events/load) event fire is returned. |
| 36 | +此配置使Selenium WebDriver等待整个页面的加载. |
| 37 | +设置为 **normal** 时, |
| 38 | +Selenium WebDriver将保持等待, 直到 |
| 39 | +返回 [load](https://developer.mozilla.org/zh-CN/docs/Web/Events/load) 事件 |
| 40 | + |
33 | 41 |
|
34 |
| -By default **normal** is set to browser if none is provided. |
| 42 | +默认情况下, 如果未设置页面加载策略, |
| 43 | +则设置 **normal** 为初始策略. |
35 | 44 |
|
36 | 45 | {{< code-tab >}}
|
37 | 46 | {{< code-panel language="java" >}}
|
@@ -123,12 +132,16 @@ fun main() {
|
123 | 132 |
|
124 | 133 | ## eager
|
125 | 134 |
|
126 |
| -This will make Selenium WebDriver to wait until the |
127 |
| -initial HTML document has been completely loaded and parsed, |
128 |
| -and discards loading of stylesheets, images and subframes. |
| 135 | +这将使Selenium WebDriver保持等待, |
| 136 | +直到完全加载并解析了HTML文档, |
| 137 | +该策略无关样式表, 图片和subframes的加载. |
| 138 | + |
| 139 | +设置为 **eager** 时, |
| 140 | +Selenium WebDriver保持等待, |
| 141 | +直至返回 |
| 142 | +[DOMContentLoaded](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/DOMContentLoaded_event) |
| 143 | +事件. |
129 | 144 |
|
130 |
| -When set to **eager**, Selenium WebDriver waits until |
131 |
| -[DOMContentLoaded](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/DOMContentLoaded_event) event fire is returned. |
132 | 145 |
|
133 | 146 | {{< code-tab >}}
|
134 | 147 | {{< code-panel language="java" >}}
|
@@ -227,7 +240,7 @@ fun main() {
|
227 | 240 |
|
228 | 241 | ## none
|
229 | 242 |
|
230 |
| -When set to **none** Selenium WebDriver only waits until the initial page is downloaded. |
| 243 | +设置为 **none** 时, Selenium WebDriver仅等待至初始页面下载完成. |
231 | 244 |
|
232 | 245 | {{< code-tab >}}
|
233 | 246 | {{< code-panel language="java" >}}
|
|
0 commit comments