Selenium WebDriver / Junit / JMeter integration

2,325 views
Skip to first unread message

Gomzi

unread,
Dec 16, 2011, 5:21:12 PM12/16/11
to webdriver
Hi,

I was able to integrate Selenium Webdriver Junit tests with Jmeter and
was able to run my tests from Jmeter.

However, since my selenium junit script launches a browser, whenever I
run it from Jmeter and increase the thread (users) count, it is
launching those many browsers on my machine and eating up all my
machines resources...

Is there a way to not launch those many browsers when I run in
Jmeter ?

Thanks,
Gomzi

David

unread,
Dec 19, 2011, 1:57:41 PM12/19/11
to webdriver
You may want to post question to JMeter forums or mailing list for
feedback as well.

There's no way to work around this issue, unless you design the JUnit
script to operate in a distributed fashion. Then maybe you can make
use of JMeter distributed testing architecture: JMeter servers in CLI
mode driven by JMeter GUI as central controller, etc., where servers
are remote machines. Each JMeter server then can run whatever amount
of browsers needed (e.g. JMeter threads, per server). But I believe
this assumes you have things set up correctly on JUnit side. I could
get tricky. Probably best to make use of Selenium Grid + JUnit +
JMeter in this case if you want to run multiple threads. Because, in
all cases, each thread "will" open a browser. Unless of course you use
the HTMLUnit driver instead of FF, IE, or other browser drivers.

Why are you using JMeter to run these anyways?

Mark Collin

unread,
Dec 20, 2011, 3:46:38 AM12/20/11
to webd...@googlegroups.com
You are effectively using jMeter to run the same test jUnit test one for
each jMeter thread. Since each jUnit test starts the browser up, runs a
test and then shuts the browser down again increasing the number of threads
will increase the number of browsers opened. In short it's doing what it
should be doing.

Performance testing requires quite a lot of hardware for the load injectors
(as you are finding out), you just need more hardware really...

Hi,

Thanks,
Gomzi

--
You received this message because you are subscribed to the Google Groups
"webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to
webdriver+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/webdriver?hl=en.


--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

David

unread,
Dec 20, 2011, 7:05:43 PM12/20/11
to webdriver
> Performance testing requires quite a lot of hardware for the load injectors
> (as you are finding out), you just need more hardware really...

And on the performance testing topic, per view of JMeter veterans,
you'd never want to use Selenium / Web Driver tests (whether through
JMeter + JUnit or something else) for the load. They would recommend
you write test completely in JMeter as HTTP requests against site/
server. Can make use of the HTTP proxy recorder of JMeter if one
doesn't want to write from scratch.

Just ask in JMeter forum / mailing list and you can have that
recommendation confirmed.

Gomzi

unread,
Dec 28, 2011, 11:17:28 AM12/28/11
to webdriver
Thanks David / Mark,

Guess I need to find a workaround for my issue...

My goal was to have my team re-use the same code written for
Functional Testing (using Selenium-Junit) to perform a basic Load /
Performance test as well and I thought integrating with JMeter would
be my solution....

It worked well for me when I wrote a C# code for VS Web-Service
Testing which I could re-use for Load Test using VS Load Test
option...

Any other tools you think I can use ?

Thanks,
Gomzi

David

unread,
Dec 28, 2011, 4:45:32 PM12/28/11
to webdriver
Gomzi,

Your best solution is either of these two:

* write new tests for load testing in your tool of choice (JMeter,
etc.).
* reuse existing Selenium-JUnit tests, with additional hardware as
needed

For reusing Selenium-JUnit tests, you'll need to distribute the tests
across machines in network or within 1 or a few machines (via multiple
instances). Each test instance on a machine can be treated like what
you do with a JMeter thread. You'll have to figure out how best to
distribute the tests in a parallel execution fashion as well. From
what I know, most people have used any or combination of the following
to achieve that: TestNG, Jenkins slaves, and Selenium Grid.

And to use the Selenium-JUnit tests in scaled up deployment for load,
you either need a super powerful server to run many browser instances
or you need many not so powerful machines to run the browsers (say
like 4 to 8 browsers per remote machine). These machines can either be
internal to your network as physical machines or virtual machines, or
you can instead make use of services like Amazon EC2, SauceLabs.com,
etc. to provision your additional machine resources to run the scaled
up tests.

Depending on your load factor, you might find Selenium won't scale to
your desired load (small loads only), without requiring a large
distributed network test. Hence most load test professionals will tell
you to use a pure JMeter or equivalent test instead.

David

Gomzi

unread,
Dec 30, 2011, 10:19:18 AM12/30/11
to webdriver
Thanks David... Appreciate all ur suggestions ..

-G

Ganesh Bhalekar

unread,
Nov 21, 2013, 12:43:31 AM11/21/13
to webd...@googlegroups.com
Hello Gomzi,
 
I read in your article that, you have successfully done the integration of Jmeter and Selenium.
Could you please help me for same.
But I am unable to find Classname & Test Method in Junit request.
 
Thanks,
Ganesh

Dmitri Tikhanski

unread,
Dec 22, 2013, 8:13:12 AM12/22/13
to webd...@googlegroups.com
As per Using Selenium with JMeter's WebDriver Sampler doc

Now try to start your test. And whatever you do, DO NOT change the "Thread Group" values, they must all be 1!

You shouldn't use > 1 Selenium thread. JMeter is powerful enough to simulate a real browser. Just make sure that you have the following:

  • HTTP Cookie Manager to support cookie-based authentication and maintain sessions
  • HTTP Headers Manager with User-Agent, Accept-Language, etc. headers - whatever browser is sending
  • HTTP Cache Manager - to simulate browser cache
  • Retrieve all embedded resources and use concurrent pool of 2-4 requests for it - to emulate images, css, etc. download behavior. 
Hope this helps,

D. 
Reply all
Reply to author
Forward
0 new messages