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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog