0

I'm facing an issue after integrating the selenium webdriver to jmeter (junit 4, jar file, Junit request).

After integration i was unable to handle the windows authentication pop up. Which means i was unable to open the browser.

These are all the steps i have done:

  1. Using eclipse,junit 4, selenium webdriver i have created test case which login into some website but for login type would be windows authentication.

  2. I have run the test case successfully in eclipse, i have exported this test case as a jar file and pasted into jmeter lib file. I have added additional libraries which are required to run the script.

  3. I have created a thread group for this i have added junit request sampler, and added listeners like results data, tree, summary report.

  4. And when i try to run the jmeter i'm getting the below error .

Thread Name: Thread Group 1-1 Sample Start: 1970-01-01 05:30:00 IST Load time: 0 Latency: 0 Size in bytes: 0 Headers size in bytes: 0 Body size in bytes: 0 Sample Count: 1 Error Count: 1 Response code: 9999 Response message: Failed to create an instance of the class:Login, reasons may be missing both empty constructor and one String constructor or failure to instantiate constructor, check warning messages in jmeter log file

Response headers:

SampleResult fields: ContentType: DataEncoding: null

  1. Kindly specify in what way we can achieve this?

Note: I want to reuse the already created scripts and do the load testing in jemeter.so only i have followed this approach.

REGARDS, VANI K

1 Answer 1

0

As per How to Use JUnit With JMeter guide

Constructor String Label

If your JUnit test class has a constructor which accepts a single String, you can set its value with this parameter. If your JUnit test class doesn’t declare such a constructor, the JUnit Sample will try to look for an empty constructor.

So double check your Login class, it should:

  • either don't have a constructor

or

  • have constructor which takes only one String as a parameter.

Another reason could be clash of .jar files, both JMeter and Selenium depend on some Apache Commons libraries and these libraries versions are different. Once you copy Selenium libraries to JMeter's /lib folder carefully examine the folder and delete duplicate .jars keeping the ones with higher version.

Also be aware that starting from version 1.3.0 Selenium Integration plugin aka WebDriver Sampler supports languages other than JavaScript so it might be easier to consider using it for your purposes.

Sign up to request clarification or add additional context in comments.

4 Comments

Yes you are right, My login class have constructors and i'm passing 4 different parameters which is a type of string.and i'm setting those values with this parameter. My question was when i set constructor with multiple values the login class is not running in jmeter, but when i remove the constructor and perform the run in jmeter working fine. So how can i achieve the parametarization in jmeter via selenium webdriver jar file. Here i'm adding my code.
Check out Accessing JMeter Variables from the JUnit Test Case of the linked guide. It clarifies how you can access JMeter Variables in JUnit Sampler
I have followed your guide but i didnt get the success in that. One thing i want to know, how you implemented the below code in webdriver junit test, because i need to send the parameter to a text box value using xpath or ID. How it is possible with this code. @Test public void setJMeterVariableTest() { JUnitSampler sampler = new JUnitSampler(); JMeterVariables vars = sampler.getThreadContext().getVariables(); vars.put("JUnitVariable", "this variable is set by " + sampler.getThreadContext().getCurrentSampler().getName()); sampler.getThreadContext().setVariables(vars); }
I have followed two ways, one is : i have used excel function to read values to the form. Next one is : @RunWith(Parameterized.class)". With WebDriver Sampler how can i use my webdriver code which is written in java? With out parametarization authentication, pop ups are easily handling with jmeter via jar file conversion using junit request sampler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.