jfbauer
jfbauer

Reputation: 1

Jmeter - get entire query string into variable

Is there a way to use the Regular Expression Extractor to grab the entire .NET encrypted query string and place it in a variable?

Example, for URL via a GET:

https:/www.website.com/folder/page.aspx?jfhjHSDjgdjhsjhsdhjSJHWed

I am trying to have ${myQueryString} = jfhjHSDjgdjhsjhsdhjSJHWed so I can replay it later in the test plan by appending the variable to a future GET.

Upvotes: 0

Views: 1565

Answers (2)

ant
ant

Reputation: 22948

First question, where do you get the GET url from, are you extracting it from the http request?

If you have it anyways either "hardcoded" or in jmeter variable you could add beanshell sampler to your test case and add the following code :

vars.put("queryParams","${__javaScript(/\?(.*)$/.exec('http://stackoverflow.com/questions/2389738/jmeter-get-entire-query-string-into-variable?testqueryparameter=&anotherqueryparam=IhavesomeValue')[1],)}");

I used http://stackoverflow.com/questions/2389738/jmeter-get-entire-query-string-into-variable?testqueryparameter=&anotherqueryparam=IhavesomeValue to test this case.

The result store in variable queryParams is testqueryparameter=&anotherqueryparam=IhavesomeValue

Is that what you were looking for?

Upvotes: 2

Tim Pietzcker
Tim Pietzcker

Reputation: 336368

(?<=\?)[^?]+$

will match everything after the last ? in the string. I hope that's what you meant.

Upvotes: 1

Related Questions