Regex Extractor is working fine at first. I can get it to pull the correct value - a groupID - from the response in the previous HTTP request. And, I turn around and use the variable in the HTTP request immediately after the Extractor. That works great as well. I can see the value in the response was the same as the one placed in the post for the next request.
Few requests later I try to use the variable again when I need the groupID passed again. But, when I look I see the default value I put in the Extractor instead of the value from the response.
My question is two fold: is this extractor only expected to generate a temporary variable?
And, if so, is there a way to plug this variable into something else for later reuse?
Or, did I just miss something?
Well, I found my mistake. It would have helped if I read the information under the post-processor section before I read about the extractor...
I did not have the extractor as a child of the HTTP request. I had it as the next step.
Once I nested it as a child all was right with the world. The variable stays as it was and is not changing after every step.
Lesson learned - RTFM. Or, at least the online documentation a bit more thoroughly!
Jamie
Related
Hello.
I met the following problem.
What I should do:
I need to make a performance test of services. I don't have documentation. In this case, I record the requested services and responses using Jmeter and the browser. Then I review every one sample and add a regular expression extractor - if it's needed.
What's the problem?
The problem that I met is when I run the script from Jmeter, some requests have two or more responses. When I use regular expression extractor or response assertion, I noticed that the extractor or assertion is applied only to the last response. So can I apply the regular expression extractor and response assertion to responses that I need?
Here are some screenshots for more details:
This picture shows that we have two responses from one request and you can see details about the first response.
This picture shows details about the second response.
This picture shows the response code for the first response.
Same as the previous picture, but I added a Response Assertion - to check if the assertion works for the first response.
This picture shows the response code for the second response.
This picture shows the assertion failure.
Why has this has happened?
Probably this happened because I hit an URL (endpoint), and this URL forces other requests, that weren't recorded. So... maybe I need to configure the recorder options in another way.
Whats the questions:
Is there is a way to choose what response I can use with a regular expression extractor? For example, there are two responses and I want to use a regular expression extractor to the first one.
Which are the best settings for recording using Jmeter?
"Whats the answers":
No, you have choice between Main sample and sub-samples, main sample only, sub-samples only or JMeter Variable
The ones which are defined in the Recording Template are most probably the best, at least they're better than anything else I've seen so far. The general approach of "recording" might be a big mistake itself, at least for Web 2.0, I believe there are way better options of replicating browser traffic.
Coming back to your first question and possible solutions: you're basically being redirected that's why you're getting 2 subresults, one with status code 302 and another one with 200
With normal Response Assertion you can only amend its configuration to take both status codes as successful:
If you want to test that exactly the first subresult has status code of 302 - you will have to go for JSR223 Assertion and implement the acceptance criteria in Groovy.
Example code:
if (prev.getSubResults().first().getResponseCode() != '302') {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('Response code mismatch, expected: 302, got: ' + prev.getSubResults().first().getResponseCode())
}
I have $dinetype variable obtained from the user.
But I would like to give response based on what value has been set in $dinetype variable. In addition to giving responses, I also need to set relevant context. How do I do this in DialogFlow?
if($Dinetype=='dineout')
ask ('which restaurant would you like to go to?')
set_context ('awaiting-restaurant')
if($Dinetype=='takeaway')
ask ('When would you like to take away?')
set_context ('awaiting-takeaway-time')
Is it programmable at all? Or is it possible to achieve something equivalent to the above in the UI?
Edit: A much easier way has been added to handle this issue directly in Dialogflow
(Updated Solution) Follow-up Intents:
After creating an intent, you can add follow-up intents now.
Intents -> Create Intent >
[Response=Prompt For Conditional Response]
Intents -> Add Follow-up Intent -> Custom/Yes/No
Then set the training praise to a matching entity you want to conditionally respond to
OLD HACKY SOLUTION:
Late reply, but maybe someone will find this useful.
If the conditional response only needs to reference a single parameter
value, then I figured out what you can do is utilize the Entity's
"Reference Value" as the response you want to give for a particular
set of Synonyms.
So you'd have an entity that looked like this:
Then, setup your intent like this, with a response of $Dinetype:
Then the end result will look like this:
And you can make whatever follow-up intent you need from there.
Down-side is Dinetype won't be as reusable. But I still think it
beats writing a fulfillment webhook every time you need a simple
conditional response.
You can't do this in the Response section directly. The Response section is meant for fairly simple responses that don't require significant logic to process. Although you can use parameters in the response, you can't give a different response based on the value of the parameter. So you can set a response to something like
I think $Dinetype is great food.
but not
{{#if $Dinetype == "Thai"}}I think Thai food is too hot{{/if}}
or anything like that
However, you can add code that sends conditional responses and contexts by implementing a Fulfillment webhook. Although you can't do this for each Intent as part of the Intent editor screen, the Fulfillment screen includes a built-in code editor.
I found a solution to my similar problem using composite entities, which may or may not be overkill for your agent. The value assigned to a parameter associated with the (composite) entity will contain a JSON structure, if a synonym in that entity was matched.
Using the "Dot" notation, you can assign the matched sub-entity's property (similar to the reference value of a normal entity) to another parameter in the Actions and Parameters section. You can have one parameter for each sub-entity and hence, you can evaluate these parameters in your response section to select each response variants:
$Parameter_A ResponseA
$Parameter_B ResonseB
....
etc.
Clunky but works. Just have to be careful to reference the property exactly as it is defined in the composite entity.
Tried with JMeter: How to know why my regular expression extractor in JMeter is not extracting the data but still not able to replace my view-state, its throwing [ViewStateException: Invalid viewstate. ] error . Please check the attachment , an my script has not _EVENTVALIDATION .
enter image description hereViewstate
viwstate2
As i am observing from your attached image
You need to pass same `Reference name` as a value of __VIEWSTATE in Next request
First Cross verify, Is your correaltion is correct or not? (you can use debug sampler to check the correlation)
If yes, then first mistake is, you had given reference name as "VIEWSTATE" in below shown snapshot
But you are passing ${jsfViewState} in other snapshot, so correct it and pass same reference name i.e. ${VIEWSTATE}
It'll resolve your issue, if issue still persists then click on encode button beside Name-Value pair because sometimes there is some mismatch in encoding format between the response which we capture and the value which we have to pass
Don't be confused with ASP.NET ViewState and JSF Viewstate, they have similar nature but different underlying technologies and different parameter names
Given you correctly correlated the value, I believe you need to change __VIEWSTATE parameter name to javax.faces.ViewState and it should work.
See Testing a JSF Application with JMeter guide for a little bit more detailed explanation on the topic and How to debug your Apache JMeter script guide for some troubleshooting techniques.
Jmeter passes default value when trying to fetch a part of response in my case is a unique name which I want to pass in next request but it takes default value:
{"status":"success","body":{"uniqueName":"jpr1444130495897","voucherType":"sales","transactions":[{"creditAccount":{"uniqueName":"acctomerge","name":"Mayank"},"debitAccount":{"uniqueName":"dacc","name":"dummyaccount"},"amount":2228}],"voucherNo":1912,"date":"01-09-2015","tag":"dummydata","description":"Q3goK8QrUo"}}
In above response I have to capture uniquename & pass it in my next request. But by default it take default value.
Bean shell assertion contains:
${__setProperty(uniqueName,${uniqueName})}
Next request is this.
Still fetching default value. Somebody please help.
As Biffen said it is better to use JSON Path Extractor that comes with jmeter plugins (http://jmeter-plugins.org/wiki/JSONPathExtractor/). It's a lot easier for JSON - just put JSON path (probably in your case just uniqueName will be enough, but you can put there $.body.uniqueName) add a variable name as uniqueName as well, so there will be no problem to use it later as ${uniqueName} in the next request. And that's it.
Oh, and your post suggests that you try to extract it with Beanshell assertion instead of Regular Expression Extractor by the way - that also can be a case.
What exact uniqueName you need to extract? There are 3 of them in your JSON data:
jpr1444130495897
acctomerge
dacc
It isn't necessary to convert variable to property to use in next request. If both requests live in the same thread group - it's enough to use reference name like ${uniqueName}
For JSON data it's more handy to use JSON Path Extractor (available via JMeter Plugins project). See Using the XPath Extractor in JMeter guide (scroll down to "Parsing JSON") for plugin installation and usage instructions.
I've got simple test plan:
Jdbs Conection
JDBC request
For Each Loop on jdbc response
|-Regular Expression Extractor (Post processor)
|-Soap Request where I need extracted value from Regular Expression Extractor
|-Response assertion
The problem is when the first loop is executed. SOAP request is filled with name of variable from Regular Expression Extractor not the value. Can anyone tell me how to get around this problem?
[Edit] test plan screen
As you can see on the first image is showing jdbc response data . On first position is value '22;1'. Second one is showing first soap request failed not a values but names of variables... Third one is showing second request filled correctly
http://postimg.org/image/owl5kue4v/
Below is screen when I add Debug Sampler to for each loop. In this situation first SOAP request is filled correctly.
http://postimg.org/image/aad3c0ngt/
My problem is how to get the same behavior like in second situation but without adding Debug Sampler?
BTW, Sorry for the images on an external server, but my rank is too low to add them here
Your test plan should be in the format mentioned in the attached snapshot:
Hope this will help