Loadster capturing rule found no matches for variable __RequestVerificationToken - asp.net-core-mvc

I'm trying to stress test my application with Loadster but every single Post method throw warning/error __RequestVerificationToken is empty or undefined as in the Get method it has the warning about capturing rule found no matches for variable __RequestVerificationToken.
This is the default way to capture in the Get method
I tried these two capture ways as well to capture
<input name="__RequestVerificationToken" type="hidden" value="
and
<input name="__RequestVerificationToken" value="
as you can see here
but still having the same warnings.
by the way, I do have this key in the HTML file.
Any clue?

After you record a script, Loadster automatically adds capturing rules for some server-generated tokens, including __RequestVerificationToken, when it sees them regurgitated from the client to the server in a subsequent request. It does this by backtracking the graph of recorded requests/responses until it finds where they originated.
When Loadster's recorder finds a match for one of these tokens, it will create a capturer on the originating step (where the value was first seen in a response) and a parameterized variable in the subsequent step(s) where the value is returned to the server.
The important thing to keep in mind is that the capturing rule is based solely on information available at the time of recording. If something is different at playback, the capturer may fail to find a value, and you'll get this error.
The most likely explanation is that an earlier step in your script failed to produce the expected state, and now the server isn't actually returning the page with the __RequestVerificationToken. For example, an earlier login in your script may have failed, and now when you request the form you're getting some kind of error page instead of the form you expected.
You can confirm this in Loadster using the Requests tab at the bottom of the script editor. After playing a script, a tree of all requests and responses appears in this section, and you can drill down to see the exact response that your server returned. Most likely you won't see a __RequestVerificationToken in this response (that's why capturing failed) but you will probably see something else that explains it. You may also need to backtrack in the tree to an earlier request/response to see where it went off the rails.

For me, the place Loadster attached the "Capture" from the recording was not correct. After recording, it attached the "Capture" rule to the POST request that resulted from the form submission. The token to be captured though was actually generated by the preceding GET request.
To correct this, I simply moved (retyped) the Capture csrfmiddlewaretoken from HTML input csrfmiddlewaretoken from the POST request to the preceding GET and it worked.
This isn't actually the case for the OP, but search results for this error are slim, so this seemed like a good place to put this.

Related

difficulty in handling correlation in 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:

How to analyze answer to the specific request in Jmeter

Here is my scenario:
5 users log in to the website which purpose is to shorten url links
(like bilty.com or tiny.cc).
Each user inputs a unique link and gets shortened result.
What I need to do is - to get some kind of analysis of this "shorten" request.
Also, I need to:
see the output (the shortened link) in this analysis.
check if the link was created or not.
check if the shortened links are correct.
make sure that the shortened link actually leads to the same website
just like the corresponding link in the input.
EDIT: I deduced that it should be made via Response Assertion, but I can't figure out how exactly.
Approach1(Grey Out-1st Thread group):- Put two request in parallel. First is full and second is redirect. Check option redirect automatically in second http request which is redirecting. Now, put compare assertion and check. This takes lot of resource.
Approach2:-Put 2 HTTPs request in parallel. First is full HTTP request without any redirect and second HTTP request is for short url and having follow redirect option checked.
Then, use regex in both (two regex used) to fetch the URLs. Check option "apply on"-> sub-samples as show for short url sampler, if it is redirecting. Not required for sampler if there is no redirect. First sampler regex uses "apply on" as "Main Sample Only" as there is no redirect.
Last compare them in the JSR223 sampler to make last sample fail.
I have used JSR223 sampler. You can also choose to have other approach also for comparison.
Hope this helps.
Update:-
Assuming you have data in two columns in csv as shown below image. Go to bin>user.properties file and put sample_variables as two column names used in the csv. Please restart jmeter if already open after editing user.properties file.
Put the first parameter in the http sampler.
Put the assertion as dynamic using second variable from the csv.
Note:- Do check the options in assertion to get what is required in your scenario. Follow redirection and Redirect Automatically have difference which required different assertion "apply to":- Main Sample or Sub-Sample. Do check them, if required.
Please check if this helps.

AJAX search - parsing and reading the URL parameters with hash tags

we've implemented a new AJAX based search on our website. We're adding the parameters and their values with # tag at the end of the main URL, when user makes further refine by applying additional filters.
This was done to enable our users to share the URL of what they were viewing. It's actually now achieved in a way that the page gets redirected and the content is generated first for the base URL. Using a Javascript function which executes onload looks at the parameters in the # tags and makes another AJAX hit.
Questions:
Why browsers are not sending the # thing to the server. i.e.; # part is not even received by the HTTP Server. It's interesting actually, browsers are not sending them at all
What is best way to get the # values? I'm looking at more of to avoid the double hit that we've implemented right now. i.e.; content is loaded already and then making another AJAX call to apply the refines.
The # value is an instruction to the browser to look for a named anchor in the document it is to load from the server. It is interpreted and actioned by the browser. The server can do nothing with it, so there's no point in sending it. If you're trying to use this for some other purpose then you'll run into difficulties - as you have found.
There is a mechanism for sending data to the server: the querystring. Append your parameters to the URL prefixed by a ?, in the form variablename=data, with successive variables separated by a &.

Adding a UNIQUE ID to the URL parameter if the XMLHttp Open Method - What does this mean and how is it done?

I need help understanding AJAX. I am going through the tutorial on W3C schools ( creating a button that opens text file on the server and displays the result in a div)
One part of the tutorials seems abstract to me, without sufficient explanation. I am sure its a pre-requisite that I have missed or not aware of, detailing below
To avoid getting a cached result in response to an XMLHttpRequest made to the server, the tutorial says one needs to ADD A UNIQUE ID to the URL parameter in the XMLHttp Open Method which has been done (in the tutorial) by adding a ?, another character (t) and an = after the file extention followed by joining a random number to the URL (using Math.random()). See code below.
A simple GET request would be like:
xmlhttp.open("GET","demo_get.asp,true); \\I can understand this
Unique ID added to URL
xmlhttp.open("GET","demo_get.asp?t=" + Math.random(),true); \\ I can't undersatnd this
'?' , 't' & a random number generator added to demo_get.asp - Why T, why not P Q R Z ?? Why "?" after .asp
Should the compiler not go bonkers and report an error if arbitary characters are added to the file location. How is the part of the URL after the file extention handled as in this case ?t= + Math.random()
This has been a case of much agony and frustration for the last 3 days cause I don't get which part of JS i have missed here, what do you call this concept and where can I read it ??
This apart, specifying message headers while sending data - What are HTTP headers and what do they mean. How do I decide what the parameters of the setRequestHeader() method shall be ?
Please help. Rest of Ajax is clear to me.
(I haven't read on the second part - the message headers. I have asked that query here to avoiding posting another question later, just in case it turns out to be as eluding and enigmatic as the UNIQUE ID concept - Apologies in case its a direct simple question I ought to read up myself)
Cache compares the requested URL with those present with it, if a unique id is added to the URL, it does not match and the browser treats it as a fresh GET request, which then is forwarded to the server. This is a standard way to bypass / disable browser caching.
Please refer this document for a better understanding of browser Caching.
See Page No 4, which explains the same thing as stated above.
http://www.f5.com/pdf/white-papers/browser-behavior-wp.pdf

ajax send parameter to jsp but failed

I am trying to send data to my jsp via:"xhr.send(projectCode);"
but apparently the parameter is not received when I am trying to realise it with System.out.print it is a null displayed.
so the story from the begining. my javascript function send the parameter to the jsp whitch construct an xml file and resend to the first one.
this will reconstruct my second dropdownList with the xml code constructed and received.
so the problem that the parameter dosent sent at all.
What should I do.
Just note in case the syntax whatever you have sent is like this:
url="postjob2.jsp?param=" + param;
After param=" keep a space and then the parameter. My issue got resolved as soon as I entered the space.
The simplest all-round solution is to run your application with a HTTP-tracer, such as fiddler for windows or wireshark. In that way you can see if the proper data is being submitted from your client to the server Given the amount of details you provide, I think this is the best starting point

Resources