Check Selenium Interviewquestions from 1 to 10 below:
Check Selenium-SDET-UIAutomation Questions set 21 to 30:
Check Selenium-SDET-UIAutomation Questions set 41-50:
Q&A Set 41-50
Defines the current session’s page loading strategy. By default, when Selenium WebDriver 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.
The document.readyState
property of a document describes the loading state of the current document. By default, WebDriver will hold off on responding to a driver.get()
(or) driver.navigate().to()
call until the document ready state is complete
In SPA applications (like Angular, React, Ember) once the dynamic content is already loaded (I.e once the pageLoadStrategy status is COMPLETE), clicking on a link or performing some action within the page will not make a new request to the server as the content is dynamically loaded at the client side without a full page refresh.
SPA applications can load many views dynamically without any server requests, So pageLoadStrategy will always show COMPLETE
status until we do a new driver.get()
and driver.navigate().to()
WebDriver pageLoadStrategy supports the following values:
normal
This will make Selenium WebDriver to wait for the entire page is loaded. When set to normal, Selenium WebDriver waits until the load event fire is returned.
By default normal is set to browser if none is provided.
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();
}
}
}
eager
This will make Selenium WebDriver 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 WebDriver waits until DOMContentLoaded event fire is returned.
none
When set to none Selenium WebDriver only waits until the initial page is downloaded.
No comments:
Post a Comment