Sorry if this has been answered already, i tried to search but could get the exact information i am after.
The issue:
I am using JMeter to run some tests on a web application, as part of one of the flow, I under a first and surname in 2 input fields and i have link (Get userid) on clicking on the link the system will generate a user name. The user name is made up of first 4 letters from surname and first letter from the firsname and number at the end example: firstname is Test and surname is Environment, on clicking the get user id link the username will be generated as 'envit1' if 'envit1' is already existing then it would generated 'envirt2'
How do I simulate the click which generates the userid using jMeter.
Apologies but I am fairly new with JMeter, please ask if you need more infomratmation.
Many thanks in advance, Kay
If you're new to JMeter the best way to get things done is recording your user ID generation steps using one of the following approaches:
JMeter bundled HTTP(S) Test Script Recorder which acts like a browser proxy
A Google Chrome Extension which is capable of recording JMeter .jmx scripts right from your browser.
You can see what requests are being sent and HTML responses using handy View Results Tree listener.
However if clicking on link isn't being recorded, it's being handled by client-side Javascript. JMeter is not a browser and isn't capable of executing Javascript so you'll have to use WebDriver Sampler as Releasematic suggests.
You can use WebDriver Sampler but in each iteration it opens browser which may increase RAM usage. There is another option is to generate user id by running JS code in "JSR223 Sampler". With JSR223 Sampler you can run JS code but can't get access to DOM, so such JS code won't work:
function () {document.getElementById("edit-buttons-cleanup").click();};
You can install the plugin pack for the JMeter WebDriver sampler. Then, using some Javascript commands, you can start either a Firefox or a headless HTMLUnit and operate upon a webpage in a Jmeter step.
Related
i am still new to JMeter and i was assigned to a work that I will need to use JMeter to perform automation testing. The idea is to write script using JMeter and run the script to fill in the forms in the website. I was curious that can JMeter use different data from the database to fill in the form of the website everytime it execute?(unique data for every user)
I have followed this tutorial (https://www.blazemeter.com/blog/fill-forms-and-submit-with-jmeter-made-easy/ ) and it succeed, however, when i try to change the parameter name (to some other names that do not matches the field name found in the inpect mode), it still works. So i was wondering how JMeter knows where to put in the parameter even i have change to a wrong field name?
As per JMeter Project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
Browsers don't do any magic, they execute HTTP Requests, wait for response and render it. JMeter in its turn can execute the same HTTP requests so traffic would be the same, however it will not render the response, but rather measure the time and collect some more metrics.
If you change the names of the inputs in the form most probably the request will be successful, to wit you will get HTTP Status Code below 400 hence JMeter will mark the result as "green", however if you inspect the response using View Results Tree listener you will see that the form is not filled and/or you still at the same page.
If you want to use JMeter for checking the data returned by the application you're testing consider using JMeter Assertions to test presence of expected values, absence of errors, set response time thresholds, etc.
You can automate the form submission or order placement usin JMeter. You can JMeter for API testing as well by adding assertions. But the main purpose of the JMeter is to test the performance of the application. Its not like selenium which performs actions on the browser whereas JMeter sends the request in various protocols to relevant server and can also simulate many users at the same time.
If you want to do extensive automation testing,JMeter isnt the ideal tool for that.
You can use webdriver sampler to run the selenium with jmeter. It requires to configure sampler and browser config which are plugin and can be downloaded using plugin manager.
For more info:-https://www.blazemeter.com/blog/jmeter-webdriver-sampler/
Now, without the plugin it is working on protocol level and not on the frontend as pointed out in the above comments.
So, yes it can depend on which layer you want to work. It can work on frontend like selenium using the webdriver plugin and can submit the form with different data as a direct request to the server without using the frontend/GUI.
Hope this helps.
It depends on what you are trying to automate. If you plan to automate API invocation where there are some pre-requisites like grabbing tokens, cookies, session IDs from the browser, then JMeter can probably be used where existing JMeter capabilities can be leveraged using BeanShell scripting and other plugins.
But if you plan to have a full blown UI automation framework then JMeter might not be an ideal choice.
I am encountering an issue with Jmeter when attempting to stress test an oracle apex website. The issue I'm having is stemming from an ajax issue.
With Jmeter I am trying to simulate a button click on page one of an application with an HTTP Post Request on the page:
/Capps/wwv_flow.ajax
I am passing in the following variables:
p_flow_id 101
p_flow_step_id 1
p_instance ${sessionid}
p_request PLUGIN=ijiPvZ-iJYfT0ihaQKUMZz3Lcjg8SHOXpMeHDzckC5k
p_json {"pageItems":null,"salt":"258015622351528748546171137179439761614"}
The first three are the applicaiton number, page number, and sessionid (the sessionid was retrieved in a earlier step using a regex extractor) Also, the p_request and p_json are encoded.
I noticed from using chrome in developer mode that the p_request string and
the last part of the p_json string often change with each run through of the button click
I was unable to find any information online that could help explain this occurs so that I could find a solution to simulate the button click.
Note I am having a similar issue on another page where I attempt to submit a simple form.
Any assistance would be greatly appreciated, thank you,
Zac
Looking into Configuring Apache JMeter for Apex article it seems you need to correlate these p_request and p_json parameters in exactly the same manner as you do for p_instance (assuming different relevant Post Processors of course)
Alternatively you can record your test scenario using a cloud-based proxy tool which is capable of exporting recorded scripts in "SmartJMX" mode with automated correlation of all detected dynamic parameters applied, check out How to Cut Your JMeter Scripting Time by 80% article for more details.
I have a JMeter Web Driver Test plan. Where I have:
a Thread group with 3 users
a Web Driver Sampler,
Firefox Driver Config
and View Results in Tree listener.
Also I have a CSV Data Set Config wherein I have mapped it to a CSV file to receive Username and Passwords.
In the Web Driver Sampler we have just written a Simple code which invokes Firefox browser, passes the url to it, passes Username and Passwords to it.
Then makes a search for a term and logs out.
Once I run this test with 3 users, the test runs fine for first and second user and fails for the third one.
And when I run the test again, First and Third user passes but fails for the second.
When I go and check on the Response message, it says it was unable to locate element.
Whereas it would have ran fine for the next user.
I'm not sure why the test is behaving like this, Can someone Help me on this issue.
Elements may not appear in DOM immediately after WebDriver get() request, I would suggest to add an extra step which will ensure that specified element is present in DOM and may be interacted with prior to clicking/typing by something like:
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
wait.until(support_ui.ExpectedConditions.presenceOfElementLocated(pkg.By.id('element_id')))
var element=WDS.browser.findElement(pkg.By.id('element_id'))
element.click()
See Using Selenium with JMeter's WebDriver Sampler guide for more details on Selenium scripting in JMeter
I have just tried jmeter examples using ant task. I got the HTML output. Now,
I built my application using c#.net,asp.net,javascript,jQuery,Ajax,Json etc.
This is the url http://localhost/test/pagemanager.aspx which shows my
LOGIN Screen. Once after login, the user can access over multiple menus(pages) to access like checking their personal data, overall student details like batch wise, registering a new student etc... My URL http://localhost/test/pagemanager.aspxremains constant at every time.
The site can be accessed by multiple users for multiple times. I needs to find a load testing. Can some one give me a configuration step to find load testng to my application.
Thanks in advance.
First of all I would recommend recording your test scenario steps starting from login via JMeter build-in HTTP(S) Test Script Recorder.
See JMeter Proxy Step by Step guide for detailed instructions.
Once you have recorded test flow you'll need to do some correlation as the nature of ASP.NET applications assumes mandatory dynamic parameters like VIEWSTATE. So you'll need to extract VIEWSTATE and similar from previous server response and add it to next request.
See ASP.NET Login Testing with JMeter for more details.
In one of my performance test scenario, user has to select one check box and then click on save button , I am able to record the scenario but unable to play. Steps are as follows:
Log in to the application
Go to Page 1 and click on any “Check box” and then click on save button.
For one user script was able to record but while running for multiple users I found that script is not checking the “Check box”. Does any body has any clue on this ?
Jmeter DOES NOT support Javascript.
As per Jmeter FAQ:
JMeter does not process Javascript or applets embedded in HTML pages.
. . . If the page uses Javascript to build up a URL or submit a form,
you can use the Proxy Recording facility to create the necessary
sampler. If this is not possible, then manual inspection of the code
may be needed to determine what the Javascript is doing.
JMeter is a tool for testing server code, not the client one. Both
recording and playback happens at the HTTP layer.
What you can do in your case is:
use any traffic inspector tool to record http request (upon "Save");
analyze request and its parameters sent;
setup request manually in jmeter.
Check/unchecking check box in your scenario doesn't generate any traffic itself BUT sets the value of request parameter sent along with further http request upon further "Save".
You have to set value of this param manually to the value which is equivalent to "checked" state of check box.
Jmeter does not recognise the elements written in javascript.
Try this:
Open Blazemeter
Go to advanced options
Select Cookies and Javascript Option under Request to Record
This solution worked for me.