在我的一个性能测试场景中,用户必须选中一个复选框,然后单击“保存”按钮,我可以录制场景但无法播放。步骤如下:
- 登录应用程序
- 转到第 1 页并单击任意“复选框”,然后单击“保存”按钮。
对于一个用户脚本能够记录,但在为多个用户运行时我发现脚本没有选中“复选框”。有人对此有任何线索吗?
最佳答案
Jmeter 不支持 JavaScript。
根据Jmeter FAQ :
JMeter does not process Javascript or applets embedded in HTML pages. . . . If the page uses Javascript to build up a URL or submit a form, you can use the Proxy Recording facility to create the necessary sampler. If this is not possible, then manual inspection of the code may be needed to determine what the Javascript is doing.
JMeter is a tool for testing server code, not the client one. Both recording and playback happens at the HTTP layer.
针对您的情况,您可以做的是:
- 使用任何流量检查工具记录http请求(“保存”时);
- 分析请求及其发送的参数;
- 在 jmeter 中手动设置请求。
在您的场景中选中/取消选中复选框本身不会生成任何流量,而是设置在进一步“保存”时与进一步的 http 请求一起发送的请求参数的值。
您必须手动将此参数的值设置为相当于复选框“选中”状态的值。
关于JMeter无法在网页中正常录制和播放 "Checkbox",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975301/