Skip to content

Add: Adding initial document for Page load strategy #240

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 4 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
187 changes: 187 additions & 0 deletions docs_source_files/content/webdriver/page_loading_strategy.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,190 @@ title: "Strategien beim Laden von Webseiten"
weight: 8
---

Defines the current session's page loading strategy.
By default, when selenium loads a page,
it follows the _normal_ pageLoadStrategy.
It is always recommended to stop downloading additional
resources (like images, css, js) when the page loading takes lot of time.

WebDriver _pageLoadStrategy_ supports the following values:

## normal

This will make selenium to wait for the entire page is loaded.
When set to **normal** the selenium waits until the
[load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event) event fire is returned.

By default **normal** is set to browser if none is provided.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("normal");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}

## eager

This will make selenium to wait until the
initial HTML document has been completely loaded and parsed,
and discards loading of stylesheets, images and subframes.

When set to **eager** selenium waits until
[DOMContentLoaded](https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event) event fire is returned.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("eager");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}

## none

When set to **none** selenium only waits until the initial page is downloaded.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("none");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}
187 changes: 187 additions & 0 deletions docs_source_files/content/webdriver/page_loading_strategy.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,190 @@ title: "Page loading strategy"
weight: 8
---

Defines the current session's page loading strategy.
By default, when selenium loads a page,
it follows the _normal_ pageLoadStrategy.
It is always recommended to stop downloading additional
resources (like images, css, js) when the page loading takes lot of time.

WebDriver _pageLoadStrategy_ supports the following values:

## normal

This will make selenium to wait for the entire page is loaded.
When set to **normal** the selenium waits until the
[load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event) event fire is returned.

By default **normal** is set to browser if none is provided.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("normal");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}

## eager

This will make selenium to wait until the
initial HTML document has been completely loaded and parsed,
and discards loading of stylesheets, images and subframes.

When set to **eager** selenium waits until
[DOMContentLoaded](https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event) event fire is returned.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("eager");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}

## none

When set to **none** selenium only waits until the initial page is downloaded.

{{< code-tab >}}
{{< code-panel language="java" >}}
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriver;

public class pageLoadStrategy {
public static void main(String[] args) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://google.com");
} finally {
driver.quit();
}
}
}
{{< / code-panel >}}
{{< code-panel language="python" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="c#" >}}
// Please raise a PR
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# Please raise a PR
{{< / code-panel >}}
{{< code-panel language="javascript" >}}
const {Builder, Capabilities} = require('selenium-webdriver');
const caps = new Capabilities();
caps.setPageLoadStrategy("none");
(async function example() {
let driver = await new Builder().
withCapabilities(caps).
forBrowser('chrome').
build();
try {
// Navigate to Url
await driver.get('https://www.google.com');
}
finally {
await driver.quit();
}
})();
{{< / code-panel >}}
{{< code-panel language="kotlin" >}}
// Please raise a PR
{{< / code-panel >}}
{{< / code-tab >}}
Loading