weixin_33709219 2016-12-28 23:16 采纳率: 0%
浏览 270

在JMeter中使用AJAX脚本

I am currently working to create test samples for an in-house Java web site using Jmeter for performance testing.

After creating / recording some scripts and re-running them, I found that some scripts are failing (not HTTP failures, the response code was 200 so it was a successful HTTP Response, but looks like server side failures) with an error "Unexpected error occurred, Page is closed". I could not figure out exact reason even after enabling high traces for this application.

I found that this web site is using lot of AJAX Requests for every sample I have collected (or most of them) and they are all recorded with samples ending with ".js". After doing a lot of google search about this issue with Jmeter, I found that Jmeter does not run Javascripts as this is not a browser.

Fair enough, went through some more details and read many solutions that talk about using Selenium web driver to run java scripts and can be used with jmeter to tackle this issue. But none of them talks about exact implementation of webdriver for running javascripts (or Ajax scripts) and having Jmeter running HTTPS Samples.

My Question is two fold:

1) How else I could debug my Jmeter scripts to confirm these errors are caused by Ajax scripts and nothing else and if not Ajax issues, what else is causing this "page closed error"

2) and how do I run web driver for Java scripts and JMeter running http samples in the same test scripts?

Any help or pointers towards a related document is really appreciated. Currently I am completely stuck and don't have any solutions that I could find reading through manuals.

  • 写回答

1条回答 默认 最新

  • 谁还没个明天 2016-12-29 00:31
    关注

    In fact you have 2 choices:

    1. Use WebDriver Sampler to perform real browser testing (this might be very resource intensive as real browsers consume a lot of CPU and RAM)
    2. Use JMeter to execute AJAX calls. JMeter cannot execute JavaScript, but JavaScript-driven HTTP requests can be recorded using i.e. HTTP(S) Test Script Recorder and replayed as JMeter HTTP Request samplers. You will need to apply some custom configuration in order to execute AJAX requests in parallel, check out How to Load Test AJAX/XHR Enabled Sites With JMeter article for details.
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器