Saturday, August 25, 2018

Timed out receiving message from renderer in selenium

This post explains how to handle Timed out receiving message from renderer issue with the help of selenium webdriver.
Whenever you are loading some page with the help of selenium driver,  then driver script wait till page is completely loaded. But sometime webdriver takes 3 to 4 mins to load page, in that case you will see TimeoutException exception in your console.
Jul 06, 2018 4:07:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[1530864721.448][SEVERE]: Timed out receiving message from renderer: 298.565
[1530864721.449][SEVERE]: Timed out receiving message from renderer: -0.004
[1530864721.469][SEVERE]: Timed out receiving message from renderer: -0.024



Solution to Overcome/Solve Timed out receiving message from renderer issue  :

When Page Loading takes too much time and you need to stop downloading additional subresources (images, css, js etc) you can change the  pageLoadStrategy through the webdriver.

As of this writing, pageLoadStrategy supports the following values :
Page load strategy for Chrome driver (Updated till Selenium v3.12.0)
1. normal:
This strategy causes Selenium to wait for the full page loading (html content and sub resources downloaded and parsed).

2. eager :
This strategy causes Selenium to wait for the DOMContentLoaded event (html content downloaded and parsed only).

3. none :
This strategy causes Selenium to return immediately after the initial page content is fully received (html content downloaded).

NOTE : By default, when Selenium loads a page, it follows the normal pageLoadStrategy.

Example :
System.setProperty("webdriver.chrome.driver","E:\\selenium\\chromedriver_2.41\\chromedriver.exe");
//mention the below chrome option to solve timeout exception issue
ChromeOptions options = new ChromeOptions();
options.setPageLoadStrategy(PageLoadStrategy.NONE);
// Instantiate the chrome driver
driver = new ChromeDriver(options);

Hope this example solve your timeout exception issue in selenium. In case of any issues, please do comment in comment box below.



No comments:

Post a Comment