atom feed1 message in net.sourceforge.lists.htmlunit-userRe: [Htmlunit-user] Simulating Browse...
FromSent OnAttachments
Don BogardusNov 20, 2012 10:20 am 
Subject:Re: [Htmlunit-user] Simulating Browser Back Button
From:Don Bogardus (
Date:Nov 20, 2012 10:20:52 am

Good point on the JS initialization. I'll open an issue for that enhancement. 

Side Note - Here are some interesting performance metrics. 

Our run of 600 tests

2 hours - Sauce Labs  40 minutes - Chrome

10 minutes - HTMLUnit 4 minutes - HTMLUnit + surefire plugin parallel execution

------------------------------------------------------------------------------------------------------------- Message: 1 Date: Tue, 13 Nov 2012 08:20:37 +0100 From: Marc Guillemot <> Subject: Re: [Htmlunit-user] Simulating Browser Back Button To: Message-ID: <> Content-Type: text/plain; charset=ISO-8859-1

Hi Don,

the pages should be surely cached but I guess that we need to take care to some initializations to allow JS to run correctly.

Cheers, Marc. --  HtmlUnit support & consulting from the source Blog:

Hi Mark, you are welcome to use my comments.    I found a workaround by caching Page objects. Shall I submit a patch?    Example using HTMLUnitDriver    class PageCachingHtmlUnitDriver extends HtmlUnitDriver{ private Stack<Page> pageCache = new Stack<Page>(); PageCachingHtmlUnitDriver(boolean enableJavascript){ super(enableJavascript); } public void purgePageCache(){ pageCache = new Stack<Page>(); } public void cacheCurrentPageForFutureBackNav(){ WebClient webClient = super.getWebClient(); WebWindowImpl loadedWindow = (WebWindowImpl)webClient.getCurrentWindow(); Page pageToCache = loadedWindow.getEnclosedPage(); if(pageCache.size() > 10){ pageCache.setSize(5); } pageCache.push(pageToCache); } public void cacheBack(){ if(pageCache.size() > 0){ super.getWebClient().getCurrentWindow().setEnclosedPage(pageCache.pop()); } } }      

------------------------------------------------------------------------ *From:* Marc Guillemot <> *To:* *Sent:* Friday, November 9, 2012 12:17 AM *Subject:* Re: [Htmlunit-user] Simulating Browser Back Button   Hi Don,  

First off, HTMLUnit has proven effective and error free while running selenium tests from jenkins. It's a luxury to not need selenium grid or sauce labs, not to mention the large speed improvements.

  thanks for the kind feedback. Would you allow us to quote you if we start a page with user feedback?  

The challenge for which I need help is simulating the browser back button.

With HtmlUnit.navigate().back() issues a GET request to the previous URI, but a "real" browser will simply display the previous page (from cache I assume) which with no server interaction . This "re-get" method does not work if the URL doesn't change during navigation.

I was about to start experimenting with Page objects from the history, but would appreciate any guidance.

  after a quick look I suppose that HtmlUnit is guilty and not the HtmlUnitDriver. Could you open an issue for it?   Cheers, Marc.

------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications!