How to Extract Multiple “View State” (almost 50) f

2020-03-31 07:46发布

How to Extract Multiple "View State" (almost 50) from the Response effectively and in a simple way other than using the regular expression extractor

Step:

  1. I basically have a page which contains almost 50 "viewstate" which needs to be fed to the next request, to process.Is there any method by which i can extract this effectively other than using 50 variables in regular expression extractor.

Any help would be really appreciable.

enter image description here

Can we regular expression extractor by setting "Match No" as "-1" and use same variable name set in the reg expression extractor and use it in sampler? Also could anyone please tell how to set the variable name too ?

1条回答
可以哭但决不认输i
2楼-- · 2020-03-31 08:10

My expectation is that VIEWSTATE is a hidden input so you can automate handling of this VIEWSTATE parameters like:

  1. Add CSS Selector Extractor to fetch hidden inputs names like:

    enter image description here

  2. Add another CSS Selector Extractor to fetch hidden inputs values like:

    enter image description here

  3. Add JSR223 PreProcessor as a child of the next request and put the following code into "Script" area:

    1.upto(vars.get('hiddenInputName_matchNr') as int, { index ->
        def hiddenInputName = vars.get('hiddenInputName_' + index)
        if (hiddenInputName.startsWith('__VIEWSTATE')) {
            sampler.addArgument(hiddenInputName, vars.get('hiddenInputValue_' + index))
        }
    })
    

    enter image description here

  4. That's it, the JSR223 PreProcessor should add all the VIEWSTATE parameters to the request in the runtime.

查看更多
登录 后发表回答