jmeter获取_VIEWSTATE和__EVENTVALIDATION参数时出现问题

时间:2015-01-26 15:11:01

标签: jmeter

我在获取__VIEWSTATE和__EVENTVALIDATION参数时遇到了一些问题。 我使用后处理器正则表达式提取器并按如下方式配置它们:

参考名称:aspViewstate

正则表达式:name =" __ VIEWSTATE" ID =" __ VIEWSTATE"值="&#34(+。);

模板:$ 1 $

比赛号码(随机0):1

默认值:ERROR_VIEWSTATE

参考名称:aspEventValidation

正则表达式:name =" __ EVENTVALIDATION" ID =" __ EVENTVALIDATION"值="&#34(+。);

模板:$ 1 $

比赛号码(随机0):1

默认值:ERROR_EventValidation

然后,我在http请求中分别替换$ {aspViewstate}和$ {aspEventValidation}的每个参数的值。

我将正则表达式提取器放在GET请求之下和POST请求之前。

我包括一个调试采样器,我得到了"错误结果":

aspEventValidation=ERROR_EventValidation
aspViewstate=ERROR_VIEWSTATE

任何人都可以帮助我解决我失踪的事情......

更新 我正在使用CSS / JQuery Extractor获取__VIEWSTATE,如下所示,并且正在运行:

CSS/JQuery Extractor Implementation:JSOUP

Reference Name: aspViewstate

CSS/JQuery Expression: input[id=__VIEWSTATE]

Attribute: value

Template: $1$

Match No. (0 for Random): 0

Default value: ERROR

但由于__EVENTVALIDATION不起作用,我使用相同的sintax:

CSS/JQuery Extractor Implementation:JSOUP

Reference Name: aspEventValidation

CSS/JQuery Expression: input[id=__EVENTVALIDATION]

Attribute: value

Template: $1$

Match No. (0 for Random): 0

Default value: ERROR

我不知道失败的是什么......

关于VIEWSTATE我已经获得了值但是系统发送了以下错误,就像是没有发送VIEWSTATE ...

错误:

    <code><pre>

[FormatException: The input is not a valid Base64 string that contains a         character that is not Base 64, more than two filler characters or an invalid   character among the padding characters . ]
   System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) +14115992
   System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) +162
   System.Convert.FromBase64String(String s) +56
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +102
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +67
  System.Web.UI.HiddenFieldPageStatePersister.Load() +200

[ViewStateException: View state invalid 
    Client IP: 
    Port: 
    Referer: http://Art/WebLogiPortal/wfmLoginD.aspx?ReturnUrl=%2fArt%2fWebLogiPortal%2fwfmDefault.aspx
    Path: /Art/WebLogiPortal/wfmLoginD.aspx
    User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
    ViewState: ${aspViewstate}]

    [HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
    System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +157
    System.Web.UI.HiddenFieldPageStatePersister.Load() +12060517
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +12315765
    System.Web.UI.Page.LoadAllState() +51
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +12308619
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +12308137
    System.Web.UI.Page.ProcessRequest() +119
    System.Web.UI.Page.ProcessRequest(HttpContext context) +99
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;        completedSynchronously) +165
    </pre></code>

我添加了一个Debug Post处理器,我意识到发送到服务器的值是字面上的变量字符(即$ {viewstate})而不是值,甚至不是默认值(错误)。 可能会发生什么?

以下是Debug Post处理器的响应日期:

HTTPSampler.response_timeout=
HTTPSampler.use_keepalive=true
    HTTPsampler.Arguments=wucLoginPortal_ScriptManager1_HiddenField=&__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=${aspViewstate}&__VIEWSTATEGENERATOR=${viewstateGenerator}&__EVENTVALIDATION=${aspEventValidation}&wucLoginPortal$__LBLHDN__=&wucLoginPortal$txtLoginAD=user1&wucLoginPortal$txtPasswordAD=user1&wucLoginPortal$txtDominioAD=art.com&wucLoginPortal$btnAceptarAD=Aceptar
TestElement.enabled=true
TestElement.gui_class=org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui
TestElement.name=4 /Art/WebLogiPortal/wfmLoginD.aspx?ReturnUrl=%2fArt%2fWebLogiPortal%2fwfmDefault.aspx
TestElement.test_class=org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy
TestPlan.comments=Detected the start of a redirect chain

1 个答案:

答案 0 :(得分:2)

我不建议使用正则表达式提取器来获取视图状态和事件验证值,如同更改属性位置,或者在多行上或有额外空格可能导致正则表达式失败。

JMeter提供了2个测试元素,旨在从HTML页面中提取值,它们是:

示例XPath定位器将如下所示:

//input[@id='__VIEWSTATE']/@value

示例CSS选择器将是

input[id=__VIEWSTATE]

在“属性”输入中指定value

有关详细信息和建议,请参阅ASP.NET Login Testing with JMeter指南。