Skip to content

Commit 0c83c87

Browse files
harsha509diemol
andauthored
Add: Adding initial document for Page load strategy (#240) [deploy site]
* Add: Adding intital document for pageLoadStrategy Signed-off-by: Sri Harsha <sri_harsha509@hotmail.com> * Add: Adding initial doc for page load strategy * Modify: Updates according to the changes suggested by @diemol Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent 8aef7f0 commit 0c83c87

8 files changed

+1504
-2
lines changed

docs_source_files/content/webdriver/page_loading_strategy.de.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,190 @@ title: "Strategien beim Laden von Webseiten"
33
weight: 8
44
---
55

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.
11+
12+
WebDriver _pageLoadStrategy_ supports the following values:
13+
14+
## normal
15+
16+
This will make Selenium WebDriver to wait for the entire page is loaded.
17+
When set to **normal**, Selenium WebDriver waits until the
18+
[load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event) event fire is returned.
19+
20+
By default **normal** is set to browser if none is provided.
21+
22+
{{< code-tab >}}
23+
{{< code-panel language="java" >}}
24+
import org.openqa.selenium.PageLoadStrategy;
25+
import org.openqa.selenium.WebDriver;
26+
import org.openqa.selenium.chrome.ChromeOptions;
27+
import org.openqa.selenium.chrome.ChromeDriver;
28+
29+
public class pageLoadStrategy {
30+
public static void main(String[] args) {
31+
ChromeOptions chromeOptions = new ChromeOptions();
32+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
33+
WebDriver driver = new ChromeDriver(chromeOptions);
34+
try {
35+
// Navigate to Url
36+
driver.get("https://google.com");
37+
} finally {
38+
driver.quit();
39+
}
40+
}
41+
}
42+
{{< / code-panel >}}
43+
{{< code-panel language="python" >}}
44+
# Please raise a PR
45+
{{< / code-panel >}}
46+
{{< code-panel language="c#" >}}
47+
// Please raise a PR
48+
{{< / code-panel >}}
49+
{{< code-panel language="ruby" >}}
50+
# Please raise a PR
51+
{{< / code-panel >}}
52+
{{< code-panel language="javascript" >}}
53+
const {Builder, Capabilities} = require('selenium-webdriver');
54+
const caps = new Capabilities();
55+
caps.setPageLoadStrategy("normal");
56+
(async function example() {
57+
let driver = await new Builder().
58+
withCapabilities(caps).
59+
forBrowser('chrome').
60+
build();
61+
try {
62+
// Navigate to Url
63+
await driver.get('https://www.google.com');
64+
}
65+
finally {
66+
await driver.quit();
67+
}
68+
})();
69+
{{< / code-panel >}}
70+
{{< code-panel language="kotlin" >}}
71+
// Please raise a PR
72+
{{< / code-panel >}}
73+
{{< / code-tab >}}
74+
75+
## eager
76+
77+
This will make Selenium WebDriver to wait until the
78+
initial HTML document has been completely loaded and parsed,
79+
and discards loading of stylesheets, images and subframes.
80+
81+
When set to **eager**, Selenium WebDriver waits until
82+
[DOMContentLoaded](https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event) event fire is returned.
83+
84+
{{< code-tab >}}
85+
{{< code-panel language="java" >}}
86+
import org.openqa.selenium.PageLoadStrategy;
87+
import org.openqa.selenium.WebDriver;
88+
import org.openqa.selenium.chrome.ChromeOptions;
89+
import org.openqa.selenium.chrome.ChromeDriver;
90+
91+
public class pageLoadStrategy {
92+
public static void main(String[] args) {
93+
ChromeOptions chromeOptions = new ChromeOptions();
94+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
95+
WebDriver driver = new ChromeDriver(chromeOptions);
96+
try {
97+
// Navigate to Url
98+
driver.get("https://google.com");
99+
} finally {
100+
driver.quit();
101+
}
102+
}
103+
}
104+
{{< / code-panel >}}
105+
{{< code-panel language="python" >}}
106+
# Please raise a PR
107+
{{< / code-panel >}}
108+
{{< code-panel language="c#" >}}
109+
// Please raise a PR
110+
{{< / code-panel >}}
111+
{{< code-panel language="ruby" >}}
112+
# Please raise a PR
113+
{{< / code-panel >}}
114+
{{< code-panel language="javascript" >}}
115+
const {Builder, Capabilities} = require('selenium-webdriver');
116+
const caps = new Capabilities();
117+
caps.setPageLoadStrategy("eager");
118+
(async function example() {
119+
let driver = await new Builder().
120+
withCapabilities(caps).
121+
forBrowser('chrome').
122+
build();
123+
try {
124+
// Navigate to Url
125+
await driver.get('https://www.google.com');
126+
}
127+
finally {
128+
await driver.quit();
129+
}
130+
})();
131+
{{< / code-panel >}}
132+
{{< code-panel language="kotlin" >}}
133+
// Please raise a PR
134+
{{< / code-panel >}}
135+
{{< / code-tab >}}
136+
137+
## none
138+
139+
When set to **none** Selenium WebDriver only waits until the initial page is downloaded.
140+
141+
{{< code-tab >}}
142+
{{< code-panel language="java" >}}
143+
import org.openqa.selenium.PageLoadStrategy;
144+
import org.openqa.selenium.WebDriver;
145+
import org.openqa.selenium.chrome.ChromeOptions;
146+
import org.openqa.selenium.chrome.ChromeDriver;
147+
148+
public class pageLoadStrategy {
149+
public static void main(String[] args) {
150+
ChromeOptions chromeOptions = new ChromeOptions();
151+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
152+
WebDriver driver = new ChromeDriver(chromeOptions);
153+
try {
154+
// Navigate to Url
155+
driver.get("https://google.com");
156+
} finally {
157+
driver.quit();
158+
}
159+
}
160+
}
161+
{{< / code-panel >}}
162+
{{< code-panel language="python" >}}
163+
# Please raise a PR
164+
{{< / code-panel >}}
165+
{{< code-panel language="c#" >}}
166+
// Please raise a PR
167+
{{< / code-panel >}}
168+
{{< code-panel language="ruby" >}}
169+
# Please raise a PR
170+
{{< / code-panel >}}
171+
{{< code-panel language="javascript" >}}
172+
const {Builder, Capabilities} = require('selenium-webdriver');
173+
const caps = new Capabilities();
174+
caps.setPageLoadStrategy("none");
175+
(async function example() {
176+
let driver = await new Builder().
177+
withCapabilities(caps).
178+
forBrowser('chrome').
179+
build();
180+
try {
181+
// Navigate to Url
182+
await driver.get('https://www.google.com');
183+
}
184+
finally {
185+
await driver.quit();
186+
}
187+
})();
188+
{{< / code-panel >}}
189+
{{< code-panel language="kotlin" >}}
190+
// Please raise a PR
191+
{{< / code-panel >}}
192+
{{< / code-tab >}}

docs_source_files/content/webdriver/page_loading_strategy.en.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,190 @@ title: "Page loading strategy"
33
weight: 8
44
---
55

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.
11+
12+
WebDriver _pageLoadStrategy_ supports the following values:
13+
14+
## normal
15+
16+
This will make Selenium WebDriver to wait for the entire page is loaded.
17+
When set to **normal**, Selenium WebDriver waits until the
18+
[load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event) event fire is returned.
19+
20+
By default **normal** is set to browser if none is provided.
21+
22+
{{< code-tab >}}
23+
{{< code-panel language="java" >}}
24+
import org.openqa.selenium.PageLoadStrategy;
25+
import org.openqa.selenium.WebDriver;
26+
import org.openqa.selenium.chrome.ChromeOptions;
27+
import org.openqa.selenium.chrome.ChromeDriver;
28+
29+
public class pageLoadStrategy {
30+
public static void main(String[] args) {
31+
ChromeOptions chromeOptions = new ChromeOptions();
32+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
33+
WebDriver driver = new ChromeDriver(chromeOptions);
34+
try {
35+
// Navigate to Url
36+
driver.get("https://google.com");
37+
} finally {
38+
driver.quit();
39+
}
40+
}
41+
}
42+
{{< / code-panel >}}
43+
{{< code-panel language="python" >}}
44+
# Please raise a PR
45+
{{< / code-panel >}}
46+
{{< code-panel language="c#" >}}
47+
// Please raise a PR
48+
{{< / code-panel >}}
49+
{{< code-panel language="ruby" >}}
50+
# Please raise a PR
51+
{{< / code-panel >}}
52+
{{< code-panel language="javascript" >}}
53+
const {Builder, Capabilities} = require('selenium-webdriver');
54+
const caps = new Capabilities();
55+
caps.setPageLoadStrategy("normal");
56+
(async function example() {
57+
let driver = await new Builder().
58+
withCapabilities(caps).
59+
forBrowser('chrome').
60+
build();
61+
try {
62+
// Navigate to Url
63+
await driver.get('https://www.google.com');
64+
}
65+
finally {
66+
await driver.quit();
67+
}
68+
})();
69+
{{< / code-panel >}}
70+
{{< code-panel language="kotlin" >}}
71+
// Please raise a PR
72+
{{< / code-panel >}}
73+
{{< / code-tab >}}
74+
75+
## eager
76+
77+
This will make Selenium WebDriver to wait until the
78+
initial HTML document has been completely loaded and parsed,
79+
and discards loading of stylesheets, images and subframes.
80+
81+
When set to **eager**, Selenium WebDriver waits until
82+
[DOMContentLoaded](https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event) event fire is returned.
83+
84+
{{< code-tab >}}
85+
{{< code-panel language="java" >}}
86+
import org.openqa.selenium.PageLoadStrategy;
87+
import org.openqa.selenium.WebDriver;
88+
import org.openqa.selenium.chrome.ChromeOptions;
89+
import org.openqa.selenium.chrome.ChromeDriver;
90+
91+
public class pageLoadStrategy {
92+
public static void main(String[] args) {
93+
ChromeOptions chromeOptions = new ChromeOptions();
94+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
95+
WebDriver driver = new ChromeDriver(chromeOptions);
96+
try {
97+
// Navigate to Url
98+
driver.get("https://google.com");
99+
} finally {
100+
driver.quit();
101+
}
102+
}
103+
}
104+
{{< / code-panel >}}
105+
{{< code-panel language="python" >}}
106+
# Please raise a PR
107+
{{< / code-panel >}}
108+
{{< code-panel language="c#" >}}
109+
// Please raise a PR
110+
{{< / code-panel >}}
111+
{{< code-panel language="ruby" >}}
112+
# Please raise a PR
113+
{{< / code-panel >}}
114+
{{< code-panel language="javascript" >}}
115+
const {Builder, Capabilities} = require('selenium-webdriver');
116+
const caps = new Capabilities();
117+
caps.setPageLoadStrategy("eager");
118+
(async function example() {
119+
let driver = await new Builder().
120+
withCapabilities(caps).
121+
forBrowser('chrome').
122+
build();
123+
try {
124+
// Navigate to Url
125+
await driver.get('https://www.google.com');
126+
}
127+
finally {
128+
await driver.quit();
129+
}
130+
})();
131+
{{< / code-panel >}}
132+
{{< code-panel language="kotlin" >}}
133+
// Please raise a PR
134+
{{< / code-panel >}}
135+
{{< / code-tab >}}
136+
137+
## none
138+
139+
When set to **none** Selenium WebDriver only waits until the initial page is downloaded.
140+
141+
{{< code-tab >}}
142+
{{< code-panel language="java" >}}
143+
import org.openqa.selenium.PageLoadStrategy;
144+
import org.openqa.selenium.WebDriver;
145+
import org.openqa.selenium.chrome.ChromeOptions;
146+
import org.openqa.selenium.chrome.ChromeDriver;
147+
148+
public class pageLoadStrategy {
149+
public static void main(String[] args) {
150+
ChromeOptions chromeOptions = new ChromeOptions();
151+
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
152+
WebDriver driver = new ChromeDriver(chromeOptions);
153+
try {
154+
// Navigate to Url
155+
driver.get("https://google.com");
156+
} finally {
157+
driver.quit();
158+
}
159+
}
160+
}
161+
{{< / code-panel >}}
162+
{{< code-panel language="python" >}}
163+
# Please raise a PR
164+
{{< / code-panel >}}
165+
{{< code-panel language="c#" >}}
166+
// Please raise a PR
167+
{{< / code-panel >}}
168+
{{< code-panel language="ruby" >}}
169+
# Please raise a PR
170+
{{< / code-panel >}}
171+
{{< code-panel language="javascript" >}}
172+
const {Builder, Capabilities} = require('selenium-webdriver');
173+
const caps = new Capabilities();
174+
caps.setPageLoadStrategy("none");
175+
(async function example() {
176+
let driver = await new Builder().
177+
withCapabilities(caps).
178+
forBrowser('chrome').
179+
build();
180+
try {
181+
// Navigate to Url
182+
await driver.get('https://www.google.com');
183+
}
184+
finally {
185+
await driver.quit();
186+
}
187+
})();
188+
{{< / code-panel >}}
189+
{{< code-panel language="kotlin" >}}
190+
// Please raise a PR
191+
{{< / code-panel >}}
192+
{{< / code-tab >}}

0 commit comments

Comments
 (0)