我在获取__VIEWSTATE和__EVENTVALIDATION参数时遇到了一些问题。我正在使用procesor正则表达式抽取器,并按以下方式配置它们:
参考名称: aspViewstate
正则表达式: name="__VIEWSTATE“id="__VIEWSTATE”value=(.+?)
模板:1美元
比赛编号。(随机数为0):1
默认值: ERROR_VIEWSTATE
参考名称: aspEventValidation
正则表达式: name="__EVENTVALIDATION“id="__EVENTVALIDATION”value=(.+?)
模板:1美元
比赛编号。(随机数为0):1
默认值: ERROR_EventValidation
然后,Im在http请求中替换${aspViewstate}和${aspEventValidation}的每个参数的值。
我将正则表达式提取器放在GET请求下面和POST请求之前。
我包括一个Debug采样器,我得到了“错误结果”:
aspEventValidation=ERROR_EventValidation
aspViewstate=ERROR_VIEWSTATE谁能帮我说说我错过了什么..。
更新:我正在使用CSS/JQuery获得__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不起作用,而且我使用的是相同的新税:
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& completedSynchronously) +165
</pre></code>我添加了一个Debug procesor,我意识到发送给服务器的值只是变量的字符(即${viewstate}),而不是值,甚至不是默认值(error)。可能会发生什么?
以下是调试后处理程序的响应日期:
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发布于 2015-01-26 15:23:47
我不建议使用正则表达式抽取器来获取viewstate和事件验证值,比如在更改属性位置的情况下,或者在多行上或拥有额外的空间可能会导致regex失败。
JMeter提供了两个用于从HTML页面中提取值的测试元素,它们是:
示例XPath定位器如下所示:
//input[@id='__VIEWSTATE']/@value示例CSS选择器将是
input[id=__VIEWSTATE]在“属性”输入中指定value
有关更多细节和建议,请参见用ASP.NET进行JMeter登录测试指南。
https://stackoverflow.com/questions/28152869
复制相似问题