简体   繁体   English

无法在 Jmeter 负载测试中处理视图/状态和事件验证

[英]Could not handle View/state and Event validation in Jmeter Load testing

I am currently load testing a .Net web application.我目前正在对 .Net Web 应用程序进行负载测试。 In which scenario is like, user will login and will do certain steps of navigation then he/she will fill one evaluation form, submit it and then logout from the application.在哪种情况下,用户将登录并执行某些导航步骤,然后他/她将填写一份评估表,提交,然后从应用程序中注销。

So for this scenario there are many GET and POST request are there.所以对于这个场景,有很多 GET 和 POST 请求。 And as its a .Net application server will do some authentication using view-State and _Event-Validation.作为它的 .Net 应用程序服务器将使用 view-State 和 _Event-Validation 进行一些身份验证。 But to handle that thing I am not sure from which request I need to fetch those 2 Parameter and pass it to which request, as this scenario is a combination of GET and POST requests.Here are the order of requests.但是为了处理那件事,我不确定我需要从哪个请求中获取这两个参数并将其传递给哪个请求,因为这种情况是 GET 和 POST 请求的组合。以下是请求的顺序。

Login (GET) Login (POST) Home (GET) Home (POST) Evaluation (GET) Evaluation (POST) --> It will load list of program according to client name Evaluation (POST) -->It will submit client and Program name to fetch the particular evaluation form Evaluation (GET) Evaluation (POST) Evaluation (GET) Logout (GET)登录(GET) 登录(POST) 主页(GET) 主页(POST) 评估(GET) 评估(POST) --> 根据客户端名称加载程序列表 评估(POST) --> 提交客户端和程序获取特定评估表的名称 评估 (GET) 评估 (POST) 评估 (GET) 注销 (GET)

So guys help me to short this thing out所以大家帮我把这件事弄短

You can handle dynamic POST parameters between requests in JMeter very easily. 您可以在JMeter中轻松处理请求之间的动态POST参数。 For viewstate and eventvalidation, add two regex extractors to your web load test. 对于viewstate和eventvalidation,将两个正则表达式提取器添加到您的Web负载测试中。

Name: Regex Extractor - ViewState
Reference Name: v
Regular Expression: name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)"
Template: $1$
Match No.(0 for Random): 1

and

Name: Regex Extractor - EventValidation
Reference Name: e
Regular Expression: name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)"
Template: $1$
Match No.(0 for Random): 1

After your recording you have to edit every HTTP Request in your Recording Controller by replacing the values of __VIEWSTATE and __EVENTVALIDATION with ${v} or ${e} . 录制后,您必须在录制控制器中编辑每个HTTP请求,方法是将__VIEWSTATE__EVENTVALIDATION的值替换为${v}${e}

This will effectively pass the viewstate and eventvalidation of the latest response in your next request. 这将有效地在您的下一个请求中传递最新响应的viewstate和eventvalidation。

You need to use one of the following PostProcessors in order to extract VIEWSTATE and EVENTVALIDATION values and get them converted to JMeter variables: 您需要使用以下PostProcessor之一,以提取VIEWSTATE和EVENTVALIDATION值并将其转换为JMeter变量:

See ASP.NET Login Testing with JMeter guide for real-life example and sample configuration of the extractors. 有关提取程序的真实示例和示例配置,请参阅《 使用JMeter进行ASP.NET登录测试》指南。

Also don't forget to add HTTP Cookie Manager to your test plan to represent browser cookies, deal with cookie-based authentication and simulate browser session. 另外,不要忘记将HTTP Cookie Manager添加到您的测试计划中,以表示浏览器cookie,处理基于cookie的身份验证并模拟浏览器会话。

You should check when view-State and _Event-Validation parameters changes.(you can easily do it with right click and view page source). 您应该检查view-State和_Event-Validation参数何时更改。(您可以通过右键单击并查看页面源代码轻松完成此操作)。 As these ones identify at which page you are. 当这些识别出您所在的页面时。

In my last script I had 23 different places where viewState changes and I had to extract and change it for 23 times. 在我的上一个脚本中,我在23个不同的地方改变了viewState,我不得不提取并更改了23次。 So no one can answer where you should change them as we do not see the responses and the app you are testing. 因此,没人会回答您应该在哪里进行更改,因为我们看不到响应和正在测试的应用程序。

You can handle it by using Regular Expression Extractor, only you need to pass your view state and Event Validation value from the GET Request to POST Request.您可以使用正则表达式提取器来处理它,只需要将视图状态和事件验证值从 GET 请求传递到 POST 请求。 And keep it in mind, every POST Request needs a different view state and Event Validation value, that will be fetched from its previous GET Request above it, it will surely help you.请记住,每个 POST 请求都需要不同的视图状态和事件验证值,这些值将从它上面的先前 GET 请求中获取,它肯定会对您有所帮助。

thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM