简体   繁体   English

使用JMeter测试JSF时提取ViewState

[英]Extracting ViewState when testing JSF with JMeter

I'm using JMeter to do some load tests on my JSF application and I'm having trouble passing the ViewState along the pages. 我正在使用JMeter对我的JSF应用程序进行一些负载测试,而我在浏览页面时遇到了麻烦。 The ViewState variable doesn't get extracted at all or it doesn't get passed along the pages. ViewState变量根本没有被提取,或者它没有被传递到页面。

I've recorded my test steps with a proxy server and this is what it looks like: 我用代理服务器记录了我的测试步骤,这就是它的样子:

第一个GET请求

I've added the Regex extractor in the first GET request. 我在第一个GET请求中添加了Regex提取器。 Tested the regex and it is correct. 测试了正则表达式,这是正确的。

第一个POST请求

In every POST request I replace the hardwired View IDs with my variable. 在每个POST请求中,我将硬连线视图ID替换为我的变量。

And what I get when I send the request is the following: 我发送请求时得到的结果如下:

请求已发送

The POST parameters are incorrect, as it sends the name of the variable. POST参数不正确,因为它发送变量的名称。

POST data: 发布数据:

loginForm%3ArequestToken=&loginForm%3Ausername=heller&loginForm%3Apassword=%21QAYxsw2%A7EDC&loginForm%3AloginButton=Anmelden& com.sun.faces.VIEW=%24%7BjsfViewState%7D &loginForm=loginForm loginForm%3ArequestToken =&loginForm%3Ausername = heller&loginForm%3Apassword =%21QAYxsw2%A7EDC&loginForm%3AloginButton = Anmelden& com.sun.faces.VIEW =%24%7BjsfViewState%7D &loginForm = loginForm

Could you tell what I'm doing wrong here? 你能说出我在这里做错了什么吗?
Thanks! 谢谢!

The ViewState parameter is an encoded value (Base64 I believe?) and may contain values that would be inappropriate if passed in a GET request through the url. ViewState参数是一个编码值(我相信Base64?),如果通过url在GET请求中传递,则可能包含不合适的值。 URL parameters are typically encoded so that special values (Eg. space -> %20) can be represented and decoded when the request reaches the server. 通常对URL参数进行编码,以便在请求到达服务器时可以表示和解码特殊值(例如,空格 - >%20)。

The issue here is that the following request is a POST meaning that the parameters do not need to be URL encoded. 这里的问题是以下请求是POST意味着参数不需要进行URL编码。

com.sun.faces.VIEW=%24%7BjsfViewState%7D&loginForm=loginForm com.sun.faces.VIEW =%24%7BjsfViewState%7D&登录表单=登录表单

The above shows that JMeter or some other process is URL encoding the ViewState in the request which is incorrect. 以上显示JMeter或其他一些进程是在请求中对ViewState进行URL编码,这是不正确的。 The value of the ViewState should simply be sent as is. 应该按原样发送ViewState的值。

Found my problem: the regex was wrong, so it couldn't find anything in the response. 发现我的问题:正则表达式错了,所以在响应中找不到任何内容。 I had to change the regex. 我不得不改变正则表达式。 Noticed it after adding a default value "NOT FOUND". 添加默认值“NOT FOUND”后注意到它。

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

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