简体   繁体   English

使用Ajax或javascript的带有发布数据的jmeter

[英]jmeter with post data using ajax or javascript

I have recorded script in jmeter for login into system. 我已经在jmeter中记录了脚本以登录系统。 However, there is a security question page is displayed once user login with correct credential. 但是,一旦用户使用正确的凭据登录,就会显示一个安全问题页面。 When user click on login button, system post the data but on second page when user answer and click on button, system post data using ajax/js script and this is not recorded in jmeter. 当用户单击登录按钮时,系统将发布数据,但在用户回答并单击按钮时,系统将在第二页上发布数据,系统将使用ajax / js脚本发布数据,这不会记录在jmeter中。 As per my understanding, js is not supported in jmeter. 据我了解,jmeter不支持js。 Now the question is how should I record second page to post security question using ajax/jmeter? 现在的问题是我应该如何记录第二页以使用ajax / jmeter发布安全性问题? Is there any solution for this? 有什么解决办法吗?

I would appreciate your inputs. 谢谢您的投入。

Thanks, 谢谢,

JMeter, when testing web services, basically does not matter whether you are using java, javascript or ajax at client side. JMeter在测试Web服务时,基本上在客户端使用Java,javascript还是ajax都没有关系。 JMeter will record HTTP requests including request headers and responses from clients and during testing it will simulate the same requests for the specified number of users(threads). JMeter将记录HTTP请求,包括请求标头和来自客户端的响应,并且在测试过程中它将模拟指定数量的用户(线程)的相同请求。 You can easily reproduce the web services if you know all the details of the web-request(host, method(get/post), request parameters, request headers, etc.). 如果您知道Web请求的所有详细信息(主机,方法(获取/发布),请求参数,请求标头等),则可以轻松重现Web服务。 If you don't know the details or facing problems then you can use Developer tools>Network (press f12 in Chrome) to get the details of web requests. 如果您不知道详细信息或遇到问题,则可以使用开发人员工具>网络(在Chrome中按f12键)获取网络请求的详细信息。 In your case, you closely observe the web request in ajax call using developer tools and provide the details in JMeter. 在您的情况下,您可以使用开发人员工具密切观察ajax调用中的Web请求,并在JMeter中提供详细信息。

If you want to pass login credentials, you can make use of user defined variables in jmeter. 如果要传递登录凭证,则可以在jmeter中使用用户定义的变量 You can set values in variables and make use it in requests as ${variable_name} 您可以在变量中设置值,并在请求中将其用作$ {variable_name}

If you need to do some computations,you can use beanshell components or BSF samplers . 如果需要进行一些计算,则可以使用beanshell组件BSF采样器

If you want extract value(to a variable) from the response data sent from the server and reuse them, then use regular expression extractor . 如果要从服务器发送的响应数据中提取值(到变量)并重用它们,请使用正则表达式extractor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM