开发者

Jmeter - get entire query string into variable

开发者 https://www.devze.com 2022-12-22 05:39 出处:网络
Is there a way to use the Regular Expression Extractor to grab the entire .NET encrypted query string and place it in a 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.


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?


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消