I want to conduct performance testing on a single page application.I want to do that programmatically .As I know performance testing for SPA includes both client_end page loading,java script execution time and server_end response time, against asynchronous Ajax calling.
I used JMeter API programmatically for running test script at server_end by following
How to create and run Apache JMeter Test Scripts from a Java program? this.
Now I want to run test script for client_end using JMeter WebDriver API programmatically.I follow this How to approach "end-client" performance testing on single-page (web) applications? but it doesn't give me enough information on how to use JMeter WebDriver API programmatically.
So my question is
How can I use WebDriver API programmatically? Any suggestion???
I would suggest the following
Use JMeter GUI and the script inside JMeter GUI like you did.
Save the script as *.jmx file
Use the following snippet for the automation
// Load existing .jmx Test Plan
FileInputStream in = new fileInputStream("/path/to/your/jmeterTest.jmx");
HashTree hash = SaveService.loadTree(in);
in.close();
// Run JMeter Test
jmeter.configure(hash);
jmeter.run();
Related
Is it possible to record JMeter scripts for performance testing Mendix App?
Yes it is, take a look at Load Testing Your Mendix Applications webinar
Record your test scenario using JMeter's HTTP(S) Test Script Recorder or JMeter Chrome Extension
Perform correlation of dynamic parameters
Perform parameterization of the test (i.e. credentials for different users and other test data)
Ensure that your test is doing what it's supposed to be doing by running it with 1-2 users/iterations and inspecting requests and responses using View Results Tree listener
Add more users and run your test in command-line non-GUI mode
Analyze the results using HTML Reporting Dashboard
More information: Building a Web Test Plan
I create a maven project using selenium web driver in eclipse to automate one web-based application. Here I also used TestNG and the programming language Java. Now I want to integrate this selenium project into JMeter and want to do performance testing so how can I achieve this?
Although it's possible to kick off a TestNG test programmatically from JMeter's JSR223 Sampler using the code like:
TestListenerAdapter tla = new TestListenerAdapter()
TestNG testng = new TestNG()
testng.setTestClasses(new Class[] { YourClassWithTests.class })
testng.addListener(tla)
testng.run()
I don't think you will get the results you're looking for.
The main limitations are:
In general it's not advised to use Selenium for performance testing
You won't get metrics and KPIs like number of concurrent users, connect time, response time, etc.
Test will be very resource intensive as one instance of browser requires 1 CPU core and a couple of gigabytes of RAM so the resource footprint will be immense.
So I would recommend converting your Selenium tests to "pure" JMeter, you can kick off JMeter's HTTP(S) Test Script Recorder and configure your Selenium tests to use JMeter as the proxy, this way JMeter will be able to intercept the relevant HTTP requests and create HTTP Request samplers which are lightweight comparing to the real browsers and this way you will get all the metrics.
I am new to jmeter. Creating a simple script seems easy via browser actions recording. Can that be done without launching the jmeter IDE?
As per latest stable JMeter version 5.4.1 it's not possible to start HTTP(S) Test Script Recorder without starting JMeter GUI
If you cannot do this for any reason the options are in:
Use JMeter Chrome Extension
Use your browser developer tools to record your test request into a .HAR file, once done you can:
either use online conversion tool to convert .har file into a JMeter script
or manually create JMeter's HTTP Request samplers by looking into requests details in the browser developer tools. If you cannot launch JMeter GUI at this stage as well you can consider using Taurus automation framework which allows creation of JMeter test plans using YAML syntax
You need to start the JMeter proxy for recording the test and it is not possible to start the proxy through available options.
There is a number of ways available for building test plans including the HTTP(S) Test Script Recorder.
Ten different ways to build JMeter Test Plans
The recording feature can be used even for complex scripts. You will have to use/add JMeter components and configure them once the recording is done to achieve the desired user actions.
Is there a way to create JMeter load test plan from .feature files? I have been looking around and I did not find any existing framework or a way to use existing specflow's feature files to create JMX files.
I don't think this is currently supported.
If you use Specflow/Cucumber for running Selenium tests (or your tests use HTTP/HTTPS protocol(s) you can configure your WebDriver initialization to use JMeter's HTTP(S) Test Script Recorder as a proxy for Selenium WebDriver instances so when you run your Specflow/Cucumber test JMeter will capture the requests coming from browsers and convert them into HTTP Request samplers.
This way you will be able to build a JMeter test plan out of your existing functional test and replay it with increased number of users. See How to Convert Selenium Scripts into the JMX Converter for more details.
As an alternative you can consider Ruby-JMeter DSL or Taurus tool which allow creating JMeter tests declaratively.
I would like to automate my JMeter recorded scripts using jp#gc - Chrome Driver Config to execute in chrome tab. Is there any way to run my recorded script in Chrome Driver Config without using javascript in jp#gc - WebDriver Sampler ?.
I am using Apache JMeter 3.2 version and for reference I have attached screenshot of my Test Plan, please verify it.
JMeter acts on HTTP protocol level so it is not possible to convert recorded HTTP requests into full browser tests. You can convert existing Selenium tests into JMeter ones, but not in the opposite direction.
You can try using i.e. Selenium IDE to record your UI-based scenario, export it to Java language and use them as a basis for your WebDriver Sampler based scripts (it supports variety of languages), however you will still need to amend the recorded script as the code, generated by Selenium IDE won't be consumed by the WebDriver Sampler "as is"