difficulty in handling correlation in jmeter - jmeter

i have identified the dynamic values in my website which i am handling through "regular expression extractor" still when i run the website the login request fails and throw error as token not found. please help,i m struggling...[this image contain the regEx extractor part and the failed login request also][1]

We cannot help you without seeing the response (at least partial) which you're getting for the /-7 request containing this hidden input with the token, you can try locating it using "RegExp Tester" mode of the View Results Tree listener and see whether your regular expression matches something or not
One thing is obvious: using regular expressions for extracting data from HTML is not the best idea, I would recommend considering switching to CSS Selector Extractor instead:

Related

Single Sign On with JMeter (SAMLResponse not getting Value)

I have a JMeter (v 5.4.1 ) script that login's to an SSO Service, using the following steps which are a result of using BlazeMeter Recorder.
GET on https://stage-aa.example.com/user/login
GET on https://stage-aa.example.com/saml_login
use this to declare SAMLRequest and SAMLResponse, Regular Expression Extractors
SAMLRequest : Regex: SAMLRequest=(.*)RelayState=(.*)
POST on https://sso.example.com/idp/EFUUU/resumeSAML20/idp/SSO.ping
This sample uses parameters:
username: user_1
password: pass_1
The parameters are named as:
pf.username
pf.pass
POST on https://stage-aa.example.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp
with Parameter:
RelayState: https://stage-aa.example.com/saml_login
SAMLResponse: PHN8730Kkascnn...uyituNN (AlphaNumeric String )
with the Parameters:
RelayState: https://stage-aa.example.com/saml_login
SAMLResponse : Long String, which i am trying to Dynamically replace using ${SAMLResponse}
SAMLResponse is not getting value for the Regex Extractor !!!!!!!!, used SAMLResponse=(.*)
GET on https://stage-aa.example.com/admin/content
This gets error: 403 Forbidden
Since the user is not logged in, using SSO
Now, without having all results as rendered HTML, I am not sure, how I can get name/value for web elements
to be able to create a regex, which can be used in correlation
I added Debug Sampler, and I am getting values for SAMLRequest but not for SAMLResponse.
here is how SAMLResponse is exhibited in the browser:
RelayState=https%3A%2F%2Fstage-aa.example.com%2Fsaml_login&SAMLResponse=PHNhbWxwOlJlc3B....
here is the Regex Extractor for SAMLResponse
Adding the complete JMeter Test plan ( jmx file ) had to obfuscate the URLs, but this will give you a pretty good idea. I can add the results of the execution if needed.
jmx file gist
Also, getting error in step 5, in the View Results Tree ( Response Body )
<br />
<b>Warning</b>: DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1 in <b>/var/www/vendor/simplesamlphp/saml2/src/SAML2/HTTPPost.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/vendor/simplesamlphp/saml2/src/SAML2/HTTPPost.php:79) in <b>/var/www/vendor/simplesamlphp/simplesamlphp/modules/redirecterrors/lib/RedirectErrors.php</b> on line <b>18</b><br />
here is a screenshot of SAMLResponse as Payload
Unfortunately we cannot help you with your regular expression without seeing the response data (at least partial) and your Regular Expression Extractor configuration. If you cannot come up with a good regular expression you can consider switching to
Particular your SAML implementation might be different, however my expectation is that SAMLResponse comes in a hidden input field so it makes more sense to consider switching to CSS Selector Extractor configured like:
You may also find How to Load Test SAML SSO Secured Websites with JMeter article useful.

Jmeter Debug Sampler Not Showing Regular Expression Extractor variables

I'm having some issues getting the variables from a Regular Expression Extractor to show in the View Results Tree.
Reg Ex and Test Plan
The Regular Expression Extractor is a child of the HTTP Request. The Debug Sampler and the View Results Tree are at the same level as the HTTP Request. I am trying to extract the Authorization Token.
API response
As you can see, I get a 200 response from the server with the Token.
View Results Tree with no RegEx variables
But I'm not even seeing the RegEx variables in the Debug Sampler. I would expect to see them, even if the Extractor didn't pull anything from the response. Am I missing a node? Looking in the wrong place? Using the wrong elements?
I've burned half a day researching and trying different things, please help.
Thanks.
Your regular expression is not correct, you should be using something like (.*) as your one will not match anything if you don't provide right boundary which you don't have. You can attempt sticking to line break character but it might not work if your token comes last
You're looking into wrong tab of the View Results Tree listener, JMeter Variables (including pre-defined ones) live under Response Data -> Response Body path
Check out How to Debug your Apache JMeter Script article to learn more about JMeter tests troubleshooting techniques.

Response Assertion / Regex Extractor Not Working in JMeter

I'm trying to extract the CSRF token so I can log in, and be able to obtain cookies, but I'm not able to.
I'm able to get a 200 response code when accessing the URL that contains the CSRF token, and I'm able to see it on the browser and the console, but my response assertion is not able to assert anything regardless of me changing the apply to, field to test, and pattern matching rules sections. My regular expression extractor isn't able to get anything either. All the headers to get to the URL are there. Any suggestions?
Forgot to mention, I'm able to get it on one server that's exactly (or should be) exactly the same as this one...
EDIT:
I placed it under the HTTP Sampler that has that response, and here is an example of what I get for my response assertion. I've also added various images.
Unfortunately you didn't share your output, so I cannot tell for sure, but although it seems your RegEx is correct in both cases, it could be that it doesn't match due to some extra spacing.
It appears that you are expecting a valid JSON, so instead of RegEx you could use JSON Extractor and/or JSON Assertion, for which extra spacing will not matter.
Example: if Response Data is
{"token":"12345"}
I can specify JSON Extractor as
(most important line is JSON Path: $.token)
and the result will be variable token with value 12345.
Here's a good online JSON Path tester, which can help you to figure out the right JSON Path.
If your goal is to check presence of a JSON Object with name of token and an arbitrary value I would recommend going for JSON Assertion instead.
Add JSON Assertion as a child of the request you would like to assert.
Use the following JSON Path query:
$.token
JSON Assertion is available since JMeter 4.0
If you still want to go for the Response Assertion - configure it as follows:
Pattern Matching Rules: Contains
Patterns to Test: {"token":"(.+?)"}

Jmeter: String Index Out of Bounds Exceptions on Xpath

Can some one please please help me on this. I am tired of looking into it.
In while loop I am reading data from csv file, navigate to web pages and get Xpath values.
I get String Index out of bounds exceptions on Xpath.
Please see this screenshot of program
Steps to execute were
1.dealers.tt -- HTTP request
2.edit_integrtaion_details.tt --- HTTP request
3.Dealer details -- HTTP Request
then Xpath entities under Dealer details
For some reason some of the records read from file... only 2 steps get executed as below.leaving other steps (3 and Xpath)
dealers.tt
edit_integrtaion_details.tt
then I get an error as
'Dealer details' : java.lang.StringIndexOutOfBoundsException: String index out of range: 8193
I tried selecting redirect automatically and follow redirects in HTTP requests to force step 3 to execute. In both cases get this error.There are no spaces for the name I get from Xpath
Most likely you are sufferin from JTidy issue #205, the options are in:
Uncheck "Use Tidy" box, if your response is valid XML or XHTML it might be the case you don't need it (unlikely though)
Compile latest JTidy from the source code and once done replace jtidy-r938.jar in "lib" folder of your JMeter installation with the brand new JTidy jar.
Switch to CSS/JQuery Extractor
Switch to Regular Expression Extractor
If XPath is totally a must you can also consider JSR223 PostProcessor and Groovy language, it has built-in support of some form of XPath. Check out Groovy Is the New Black article for more details.

JSON Path Extractor in JMeter

I am new to jmeter. Can anyone help me to use a response object of one request to be passed as a request header of next HTTP request ?
Let me explain.
I am getting an access token along with the response of login in my app:
{: "responseCode":18, : "message":"Successfully logged in.", : "responseObject":"8zWExE4eSdhcJDwnW9MgIw=="}
No I want to use this access token (8zWExE4eSdhcJDwnW9MgIw) as one of the parameter of next request.
I used JSON Path Extractor for this.But its not working.
I am using JSON Path Extractor as well and it works great if it is properly configured.
Just put it into request and fill fields:
Variable Name: access_token (or any other you want to use later in request like this ${access_token})
JSON Path: responseObject should be enough if the JSON you pasted is full response (thjose additional colons are just some mistakes when copy-pasting or the JSON is corrupted?)
Default Value: I always use some value like 'NotUpdated!' here so I can assert in the next step or at least see it easily in request.
Not seeing the full response it is quote hard to come up with a correct JSON Path expression.
Given what you posted it should be something like $.responseObject
See JSON Path Syntax guide for queries syntax examples and Using the XPath Extractor in JMeter (scroll down to "Parsing JSON") for plugin installation instructions and XPath to JSON syntax mapping.
Just in case anybody would face an issue with multiple variable extractions using JSON Extractor (like me), make sure to:
List the names of variables/path expressions/default values using a semicolon as a separator.
Provide default values for every variable.
The second point is apparently required, and I only found out about it from this
Medium post.

Resources