I am new to selenium, I'm facing "Time out receiving message from the renderer" in chrome browser while running test with selenium 2.41 and chrome 2.9x. I have tried many tests to reproduce the issue, but it occurs inconsistently. Is there any specific reasons for this issue?.
-
The code for a small test case might help.– user246Commented Jun 24, 2014 at 13:39
-
1that error typically means there is a version mismatch between chrome and chromedriver.– Corey GoldbergCommented Mar 7, 2018 at 14:28
-
One of the issue is, after login, chrome has opened a dialog asking for proxy credentials. Since this dialog not visible in failure screenshot, so able to capture the issue after manually checking from the node machine.– VigneshCommented Nov 29, 2018 at 15:07
10 Answers
It looks like this issue has been logged as a bug for Selenium but has not yet been fixed: Issue 402: webdriver hangs on page load and does not give control back for script execution
They are looking for a specific repro, maybe you could help them out by posting your specific repro?
One person reported that removing any driver timeout options from their code solved the problem:
//driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
//driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
//driver.manage().timeouts().setScriptTimeout(60, TimeUnit.SECONDS);
-
-
worked w/o any timeout options: String webDriverURL = "http://" + environmentData.getHubIP() + ":" + environmentData.getHubPort() + "/wd/hub"; driver = new RemoteWebDriver(new URL(webDriverURL), capability); // driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); // driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS); driver.manage().window().setSize(new Dimension(1920, 1080)); Commented Jan 3, 2017 at 11:00
-
But then how do you handle timeouts? Although in the log messages it says [SEVERE] looks like everything is fine for me... other than having an annoying output in my logs Commented May 20, 2020 at 17:53
I am not saying this is the solution but I want to share my experience after investigating a day on this. The problem with our site was actually because of the time it took for a third party to load a page source when using Google tagging (GTM).This can be overlooked by adding a chrome extension like Ghostery and block all the tags. Or better you can ask your developers to turn off tagging on pre-prod. With the former approach you can load the chrome profile with Ghostery as below.
DesiredCapabilities capabilitiesChrome = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("--always-authorize-plugins");
options.addArguments("load-extension=C:/Users/hemanand.rajamani/AppData/Local/Google/Chrome/User Data/Default/Extensions/mlomiejdfkolichcflejclcbmpeaniij/7.1.0.49_0");
options.addArguments("user-data-dir=C:/Users/hemanand.rajamani/AppData/Local/Google/Chrome/User Data/Default");
capabilitiesChrome.setCapability(ChromeOptions.CAPABILITY,options);
try {
desiredBrowser = new RemoteWebDriver(new URL("http://" + hubHost + ":" + hubPort + "/wd/hub"),
capabilitiesChrome);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Hope this helps someone.
So I've solved this, but my solution is an awful hack. The only thing it has going for it is that it has worked, at least for us. Here's the code:
Here's the code at the center of the solution:
webdriver.get('about://blank')
my_script = 'var a = document.createElement("a");' \
'var linkText = document.createTextNode("%s");' \
'a.appendChild(linkText);' \
'a.title = "%s";' \
'a.href = "%s";' \
'document.body.appendChild(a);' % \
(url_to_use, url_to_use, url_to_use)
webdriver.execute_script(my_script)
webdriver.set_page_load_timeout(20)
webdriver.click_element_by_text('css=a', url_to_use)
if page.loaded() is False:
webdriver.click_element_by_text('css=a', url_to_use)
if page.loaded() is False:
webdriver.click_element_by_text('css=a', url_to_use)
if page.loaded() is False:
webdriver.click_element_by_text('css=a', url_to_use)
Details here:
http://testautomationarchitecture.blogspot.com/2016/10/python-selenium-and-dreaded-timed-out.html
-
4Your blog post is a good one, but could you please add the key points of your solution to your answer here. We much prefer to have the important aspects of a solution in the body of the answer with references to more details. Commented Oct 12, 2016 at 19:39
-
I think the key point of solutions is "webdriver.set_page_load_timeout(20)"– han058Commented Mar 18, 2020 at 2:18
-
You'd think that, but you'd b wrong. We tried just that on it's own. I spent months with this as a background task before I came on this solution. And as I said, it's really an awful hack. But one of the biggest problems in GUI automation is synchronization... Since we did this, it hasn't happened again. Commented May 14, 2020 at 18:45
I had been dealing with this problem for 6 months or so and every time I was hoping it would be fixed in the next update but it didn't.
So for sake of saving time of others who have run into the same or similar problem, the issue is that for some reasons the page has not loaded completely and it will eventually timeout.
I firstly tried running a code in future using the Timers but that didn't help much either.
The best and WORKING solution I found was to create my own extension that all it does is to stop the page:
manifest.json:
{
"manifest_version": 2,
"name": "Amir's Extension",
"version": "1.0.0",
"content_scripts": [
{
"all_frames": true,
"matches": ["*://*/*"],
"js": ["content.js"],
"run_at": "document_start"
}
]
}
and in the content.js file:
setTimeout(() => {window.stop()}, 10000);
setInterval(() => {window.stop()}, 20000);
So I also needed to enable it:
Path currentRelativePath = Paths.get("");
String s = currentRelativePath.toAbsolutePath().toString();
chromeOpt.addArguments("--load-extension="+s+"/stopper");
And yay! I haven't had a single time-out issue yet!
-
Fantastic solution! Extending the page load timeout to infinity just wasn't working. Commented Jun 15, 2023 at 16:09
Thanks for your responses finally I solved it cutting out some plugins and blocked some third party ads before starting the tests.
Solution 1: There are some plugins like flash player which may hangs the browser inconsistently waiting for some resource during test run, try disabling such plugins while starting the test using the chrome switches. http://peter.sh/experiments/chromium-command-line-switches/
Solution 2: The browser might hang waiting for some third party ads. Try disabling ads using some ad blocker extension or block the url pattern using the custom proxy configuration.
For inconsistent browser hangs, Try to find which process hangs the browser. 1.Unlike firefox chrome creates separate process for browser, tab, extension and plugins. 2.When the browser hangs check is there any new process(shift+Esc) like Web Worker:blob appended with an third party url, then follow #2 3.or else if there are more separate process opened for plugins try #1
I'll share my case:
I had this issue with my Django selenium tests (django==1.7.12 and selenium==2.53.1) with ChromeDriver 2.21.371459 and Google Chrome 48.0.2564.116.
I was able to isolate the issue. In my case it was happening only for pages referencing a static file (an image in a HTML tag for instance http://cdn.local.myproject.net/static/myimage.png) on my custom local cdn domain. The issue was not present if I used a relative path "/static/myimage.png" or localhost "http://127.0.0.1/static/myimage.png so I figured it was a DNS problem.
I was able to bypass the problem by using the --dns-prefetch-disable
option of chrome.
Example in Python:
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
driver = Chrome(chrome_options=options)
I don't know if this is the general case but hopefully it can help some of you.
try-catch this timeout exception:
try{
// your code with timeout exception
} catch {
case e: Throwable => {
println(Console.RED + " Alert-окно! " + Console.RESET)
// println(Console.MAGENTA_B + "press..." + Console.RESET); Console.in.readLine()
try {
println(" 13 alert. close trying ")
println("e.getCause: " + e.getCause)
remote20.switchTo().alert().accept()
remote20.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS)
remote20.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS)
} catch {
case e: Throwable => {
println(" 13 alert. no alert-window")
}
}
// println(Console.MAGENTA_B + "press..." + Console.RESET); Console.in.readLine()
}
}
It causes because page took long time to load , you need add additional line to your chromedriver option. Please refer the below link for more information : Timed out receiving message from renderer in selenium
To Execute test cases parallel in Jenkins Headless mode use the below commands
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--aggressive-cache-discard");
options.addArguments("--disable-cache");
options.addArguments("--disable-application-cache");
options.addArguments("--disable-offline-load-stale-cache");
options.addArguments("--disk-cache-size=0");
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--no-proxy-server");
options.addArguments("--log-level=3");
options.addArguments("--silent");
options.addArguments("--disable-browser-side-navigation"); options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
options.setProxy(null);
-
5How does this answer the original question? Also most of these arguments are not needed to run the driver headless. Commented Jan 6, 2020 at 12:54
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
In my code, above 2 lines used and I commented the second line, it's working fine.
//driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
-
2This is either a comment on the original question or a new question - I'm not sure which, but it isn't appropriate as an answer. Commented Jun 23, 2015 at 11:05
-
I don't see this as an answer to the question being asked. Can you please explain what you are trying to convey with this content as an answer? Commented Jul 10, 2015 at 17:08
-
The proposed solution doesn't even work in my case Commented May 20, 2020 at 17:50