Running test script recorder error in JMeter - jmeter

I have to perform load testing of a particular application and am using JMeter for that.
In my application, I have a unique access token which will be obtained on successful login and this token has to be passed to the consecutive requests to obtain the response.
Now I have added a recorder for my test plan and ran the HTTP test script recorder.all the browser action is recorded in the recorder of the test plan.
the structure of my test plan and workbench is as mentioned below.
**Testplan-**
*Threadgroup*
Recorder-
//inside the recorder
[Request1-login
Request2-To load the uploaded images by the corresponding user]
//Outside the recorder inside the thread group,
View Results Tree
HTTP Cache Manager
HTTP Coockie Manager
**WorkBench**
HTTP(s) Test Script Recorder
By default, there is a header manager for each request when recorded what I did was to add the extracted token obtained using json extracter of the request1 to the header manager of the request2 in the recorded script.
The token is getting passed along with the request header as shown below but the response obtained is unauthorised.
Request Headers:
Connection: keep-alive
Referer: http://localhost/
Accept-Language: en-US,en;q=0.5
Origin: http://localhost
Content-Type: application/json;charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: application/json, text/plain, */*
Authorisation:91kLM68tdMBoDFRURArvdmwYgWV9Nr2sHYDwivTM.91kLM68tdMBoDFRURArvdmwYgWV9Nr2sHYDwivTM.Arvdm_M68-BoDFRURArvdmwYgWV9Nr2sHYDwivTM
Content-Length: 0
Host: http://localhost/phpmyadmin/index.php
I have checked the same token in postman and am obtaining the correct response.
am I missing out something?Is there anything else I have to take care of before running the recorded test script?Please help

Compare exactly (Header + Body) requests :
sent by postman
vs request sent by JMeter
There must be a difference somewhere.
And in CookieManager ensure you have set Policy to "standard" if using JMeter 3.x
As per your comment:
Authorization was misspelled (Authorisation)

Related

How to change Content Length in Jmeter

I am stuck at very critical junction of my scripting in Jmeter, I have a requirement to upload a file on Azure storage and a Microservice which analyze the blob data to process further but it looks for certain size, example 8081920 bytes. I am successfully able to upload the the file of same size on Azure storage but the service returns size Mismatch.
If I upload the same file using Postman, service is able to process the image successfully. Below is the Postman request Header
x-ms-blob-type: BlockBlob
Content-Type: image/raw
User-Agent: PostmanRuntime/7.26.10
Accept: /
Postman-Token: b9384ac9-7fbe-4ab8-834b-aef0d8114588
Host: xxxxxxx.blob.xxxxxx.windows.net
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 8081920
Jmeter Request Header:
Connection: keep-alive
Content-Type: image/raw
Accept-Encoding: gzip, deflate, br
Accept: /
x-ms-blob-type: BlockBlob
Content-Length: 8082155
Host: xxxxxxx.blob.xxxxxx.windows.net
User-Agent: PostmanRuntime/7.26.10
Any idea how to resolve this from where jmeter sending additional 235 Bytes but Postman doesn't.
Thanks,
Akshat
Content-Length header is being automatically calculated by both tools as:
sum of request headers (bytes) + request body (bytes)
Given you haven't provided the body we cannot state where the inconsistency lives, from what I can see is that Postman sends Postman-Token and JMeter doesn't so JMeter's Content-Length should be less
In case of multipart file upload the discrepancy can be caused by different boundaries but it shouldn't have any impact on the image processing.
In any case given you're able to successfully upload the file using Postman and cannot do this using JMeter - you can just record the request from Postman using JMeter's HTTP(S) Test Script Recorder - this way you will get confidence that requests are exactly the same. Just make sure to copy the file you're uploading to "bin" folder of your JMeter installation, this way JMeter will be able to properly capture the request.
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Bad request as a response in jmeter

I'm using a POST request in jmeter as below,
POST https://aumaz-ap-perf-ess-web-2.aumaz-ase-dev002.p.azurewebsites.net/signalr/connect
POST data:
clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22bulkprocesshub%22%7D%5D&connectionToken=DWGWhf7zGj9TyO4cZn2kqH%2Bennba0V7qyAuAE2wIeu3vIoj%2FrLXemcaBz%2Fto3JjEs%2BaVviiFagxtax8E9PbE36cnBAlrByzw5qBwmIu9glop75vPY3XI0me52yTDiWC%2B9Zoalg%3D%3D&processId=b47fe282-8112-4a11-a18c-7629ac31b816&transport=longPolling
Request Headers:
X-Requested-With: XMLHttpRequest
Accept: text/plain, */*; q=0.01
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Referer: https://aumaz-ap-perf-ess-web-2.aumaz-ase-dev002.p.azurewebsites.net/ESS/DataType
Connection: keep-alive
Connection: keep-alive
Host: aumaz-ap-perf-ess-web-2.aumaz-ase-dev002.p.azurewebsites.net
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Length: 315
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
If I use the same POST request in browser i can able to get the exact response. But in jmeter I'm getting the response as Bad request.
As of now, I'm using jmeter 3.01 and I have installed all the certificates needed. Can anyone please give solution for this
The most problem here seems to be that server doesn't respond with any details of what's wrong with the request. Correct?
Then do two things:
1) Install Fiddler, capture what you're sending through browser, and through JMeter, compare.
That may give you a clue what's the difference.
2) Reach server logs and see what's going on, there may be way more intrinsic information on why request was considered invalid.
I have finally got a solution. If I pass those parameters in parameters it doesn't work but i gave all the parameters with & in the path itself.
And used ${__urlencode{parameter}} to encode the parameters which are passing as encoded value and then I didn't face any Bad request issue.
Even now, I don't know how it worked. But finally got a solution by this way.

jMeter Login issue with MVC and Anti Forgery

I am trying to load test my Website using jMeter.
I am getting issue with my login page. I have passed the __RequestVerificationToken value in login page by capturing it via RegEx as shown:
Field to check: Body.
Reference Name: token.
Regular Expression: <input name="__RequestVerificationToken" type="hidden" value="(.*)" />.
Template: $1$
I am still getting the same error with response as :
<title>The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.</title>
<b> Exception Details: </b>System.Web.Mvc.HttpAntiForgeryException: The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.<br><br>
More details from the Request tab in View tree results:
POST data:
__RequestVerificationToken=%24%7Btoken%7D&UserModel.UserName=pm&UserModel.Password=Abc1234D
Cookie Data:
ASP.NET_SessionId=l0cvy41ons0xv1t3e5glx2j5; __RequestVerificationToken_L0NyZWlzc1dlYg2=elGNi5_GoW2DYFM-obeXg9DHsihM26jv8HgT4IEpjngwc1gfJ4lRTboi3t-UV4L9485dM_9bdAVfRZKauTIXAZoKvNt2Q9R0yW19ZQIO17A1
Request Headers:
Connection: keep-alive
Referer: http://172.52.50.137/CreissWeb/
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Length: 91
Host: 172.52.50.137
HTTP Request:
__RequestVerificationToken ${token} false true
UserModel.UserName pm false true
UserModel.Password Abc1234D false true
Any help will be highly appreciated. !!
Your regular expression extractor does not work as you expected. The POST data clearly shows that __RequestVerificationToken=${token}.
Try to change the Regular Expression to name="__RequestVerificationToken" type="hidden" value="(.*)" & see if it helps.
If it does not work, Post the HTTP response you get.

Servicenow Export from Java code--- 401 error

i am trying to read a url for JSON export from servicenow in java code but getting 401 authentication error please advise:
i'm using this link:
"https://servicenow.com/incident_list.do?JSONv2&sysparm_record_count=2"
-- Mocked up domain name..
I would suggest using a proxy (ie. Fiddler, BurpProxy, Runscope, nGrok) to see the HTTP request you are sending to ServiceNow from your code. The HTTP Request must contain an Authorization header (Basic Auth) as shown in sample below. You'll want to make sure the request that is being created and sent by your Java code has a correctly formatted and valid Authorization Header.
Authorization: Basic {this should be your credentials Base 64 encoded}
GET https://demo006.service-now.com/incident.do?JSONv2&sysparm_sys_id=d71f7935c0a8016700802b64c67c11c6 HTTP/1.1
Host: demo006.service-now.com
Authorization: Basic {this should be your credentials Base 64 encoded}
Accept-Encoding: gzip, deflate, compress
Accept: */*

prototypeJS Ajax call vanishes

I've got a problem with an Ajax request in my web project. Most of the time it works just fine but sometimes there is simply no request from the client (it does not show in wireshark), FireBug just shows the request marked red.
Project looks like the following:
Java Backend with JSPs, Client is using the Firefox Browser
The request is done via prototypejs using the Ajax Updater function. I can debug the request preparation via firebug until the Ajax Update function fires the request but then no request is listed in my wireshark output (although all other request are listed just fine).
So I have a (sometimes) vanished Ajax request with no error and no clue where to look :( Any help would be much appreciated.
Request:
[...]/ajax/gruppe/loadTreeList.do?ajax=true&tstamp=645&context=GRUPPE&level=0&it‌​emid=0
RequestHeader:
Accept text/javascript, text/html, application/xml, text/xml, /
Accept-Encoding gzip, deflate
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Cookie JSESSIONID=326D8AEAAFD254760CEC8D050734807E
Host localhost:8080
Referer [...]/domain/druck/gruppe.do
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20100101 Firefox/17.0
X-Prototype-Version 1.7.1
X-Requested-With XMLHttpRequest
There is no response.

Resources