Close and Re Open browser per sampler (clear cache)

2,443 views
Skip to first unread message

Pablo Jiménez Vélez

unread,
Jan 21, 2014, 5:44:01 PM1/21/14
to jmeter-...@googlegroups.com
Hello all.

This is my situation:

I have multiple tests that I need to execute in order to get the load time, basically every test is a different page.
I set up multiple samplers inside a thread group and everything seems to be working fine, the problem is that after the first test, the browser is not closed, instead the following tests just re use the same browser session, this causes the measurements starting on test #2 to be inaccurate because the browser already has all the cache from test #1. I need to get the times of every page from a cold start (no cache)

On regular selenium tests I would just close the browser after every test and one a new one at the beginning of every test. Is there a way to do this using this plugin? or is there another way to accomplish the same goal? (have a clear cache on every test)

Thanks!

Cheen-Pin Lim

unread,
Jan 22, 2014, 12:35:41 AM1/22/14
to jmeter-...@googlegroups.com
Hi,

Under the experimental tab for your browser config there should be an option to restart the browser after each request. This should clear everything (cookies as well as cache).

Hope that helps.

regards,
CP


--
You received this message because you are subscribed to the Google Groups "jmeter-plugins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jmeter-plugin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Pablo Jiménez Vélez

unread,
Jan 22, 2014, 11:28:08 AM1/22/14
to jmeter-...@googlegroups.com
Hi CP 
Thanks for the tip, but this still not solve my issue.
When I enable that it closes the browser on each loop.

I have a Thread Group with 4  samplers, each sampler is a script. If I enable that option it will close the browser after the 4th sampler has run and open a new one on the next loop.

What I need is to clear the cache (and cookies and everything) at the beginning of each sampler.

The browser is automatically initialized on the WSD.browser variable, Is there a way to re-initialize that variable? 

I tried closing he browser at the end of the first sampler and creating a new browser on sampler #2

var selenium = JavaImporter(org.openqa.selenium);
var ffDriver = JavaImporter(org.openqa.selenium.firefox.FirefoxDriver);
WDS.browser = new ffDriver.FirefoxDriver()

And this actually works, it will close the browser and open an new instance on Sample #2, the problem is that apparently the plugin saves a reference to the instance that is crated on start and so, even when the scripts actually completes successfully it is marked as failed with this error:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.34.0', revision: '11cd0ef93615408e0b6b3bfa28defe125906461a', time: '2013-08-06 11:43:14'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.7.0_51'
Driver info: driver.version: RemoteWebDriver

Any ideas?

Cheen-Pin Lim

unread,
Jan 22, 2014, 2:28:08 PM1/22/14
to jmeter-...@googlegroups.com

Hi Pablo

What I had previously done was to use a once only controller to contain the web driver samplers. The combination of this and the browser config should give you what you want.

Let me know how you go

CP

karthik.a...@gmail.com

unread,
Nov 30, 2019, 5:52:17 AM11/30/19
to jmeter-plugins
Hi

I am having reverse kind scenario as your's. My scenario is as follows

--Creating one thread group >> under this I am doing web application login and token passing which is finally opens landing page

Now I want to create one more thread group [threadGroup2] under this I want to do actions on landing page by passing multiple users count.

Is it achievable? if yes, please guide me how can I do this.

Thanks
Karthik A
Reply all
Reply to author
Forward
0 new messages