我最近开始在Jmeter上工作,我的脚本因403错误代码而失败。我使用的是Blazemeter录制的脚本,因此默认情况下添加了Cookie管理器。另外,如果我只是在浏览器上执行请求,它就可以正常工作。
Sampler Result -
hread Name: Thread Group 1-1
Sample Start: 2018-12-03 14:49:03 AEDT
Load time: 15
Connect Time: 0
Latency: 14
Size in bytes: 1069
Sent bytes:744
Headers size in bytes: 259
Body size in bytes: 810
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 403
Response message: Forbidden
HTTPSampleResult字段: ContentType:text / html 数据编码:nu
请求正文 GET https://www.tESTwEBSITEtOBEeNETERED.com.au/enable-cookies
获取数据:
Cookie Data:
frontend=678e630f5a6f37fc997a718be54f75ba;
frontend_cid=Ze0Sr0REGmigveWw;
CUSTOMER_SEGMENT_IDS=deleted;
CUSTOMER=deleted;
CUSTOMER_INFO=deleted;
CUSTOMER_AUTH=deleted;
CUSTOMER_RATES=deleted;
CACHED_FRONT_FORM_KEY=AxoMsaUGdvGAQ1N1;
visid_incap_39856=opEg/ZzKQuCez9glT1rT55OnBFwAAAAAQUIPAAAAAADml4Q7vfuGxMnzp+hJTfV1;
incap_ses_435_39856=JxltQBT4wVV0t25WbG8JBpOnBFwAAAAA4SHNX9lfr1ZfxCbkdlxKyg==;
___utmvmiluoDOB=a;
___utmvailuoDOB=a;
___utmvbiluoDOB=a
响应数据
<html style="height:100%">
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script type="text/javascript" src="/_Incapsula_Resource?SWJIYLWA=719d34d31c8e3a6e6fffd425f7e032f3"></script>
</head>
<body style="margin:0px;height:100%">
<iframe src="/_Incapsula_Resource?CWUDNSAI=20&xinfo=1-40768151-0%200NNN%20RT%281543808943058%20210%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B16%20U5&incident_id=435001350115211124-218735417329125489&edet=16&cinfo=ffffffff" frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula incident ID: 435001350115211124-218735417329125489</iframe>
</body>
</html>
答案 0 :(得分:1)
如果相同的请求在浏览器中有效,而在JMeter中则无效,则请求headers或参数中必须存在不匹配项。
现代的Web应用程序广泛使用动态请求参数,主要是出于security的原因,如果您未执行任何correlation-最有可能的是您的测试方案在登录步骤失败,因此有HTTP Status 200 JMeter认为它是成功的。使用View Results Tree侦听器检查以前的采样器的响应,以确保您的测试能够完成预期的工作,并且每页都与预期结果相匹配。