简体   繁体   English

如何将api的响应传递给jmeter中的junit请求采样器?

[英]How to pass a response of a api to junit request sampler in jmeter?

I have integrated selenium code with JMeter using JUnit request sampler. 我已经使用JUnit请求采样器将硒代码与JMeter集成在一起。 I want to navigate to a URL which I will get from an API response. 我想导航到将从API响应中获取的URL。 For this, I can pass a runtime value (URL) to the JUnit jar file. 为此,我可以将运行时值(URL)传递给JUnit jar文件。 To achieve this, I need to pass response of an API to the JUnit sampler. 为此,我需要将API的响应传递给JUnit采样器。 How can we do this? 我们应该怎么做?

you can add a "Regular Expression Extractor" to your API-Sampler to get the necessary string from the response. 您可以在API采样器中添加“正则表达式提取器”,以从响应中获取必要的字符串。 The extracted string can be used by ${ReferenceName} . 提取的字符串可由${ReferenceName}

Hope this is what you are looking for. 希望这是您想要的。

Best tifi 最佳电视

  1. You can extract the "interesting" value using any suitable JMeter PostProcessor and store it into JMeter Variable 您可以使用任何合适的JMeter PostProcessor提取“有趣的”值并将其存储到JMeter变量中
  2. The variable can be used in the JUnit Request sampler like: 该变量可以在JUnit Request采样器中使用,例如:

     String value = JMeterContextService.getContext().getVariables().get("your_variable_name_here"); 

    You will need to link your project with Apache JMeter Core in order to have access to JMeterContext class 您需要将您的项目与Apache JMeter Core链接,才能访问JMeterContext类。


In the majority of cases it's easier to go for WebDriver Sampler in order to get Selenium integration 在大多数情况下,为了获得Selenium集成,更容易使用WebDriver Sampler

暂无
暂无

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

相关问题 如何在Jmeter中将变量从sampler1响应传递到sample2请求 - How to pass variables from sampler1 response to sample2 request in Jmeter 使用JUnit Request Sampler与Jmeter运行Selenium脚本时出错 - Error while running Selenium Scripts with Jmeter using JUnit Request Sampler Jmeter:如果在响应Cookie中找不到特殊字符串,则调用HTTP采样器请求 - Jmeter: Recall HTTP sampler request if a particalar string is not found in response cookie 在 Jmeter 中,如何等待前一个采样器(JDBC 请求)完成,然后启动新的采样器请求(Http 请求) - In Jmeter , how to wait for a previous sampler(JDBC Request) to finish and then start the new sampler Request(Http request) JMeter - 如何将多行响应数据传递给 ForEach Controller 请求 - JMeter - How to pass Multiline response data to the ForEach Controller request 如何在jmeter中为java采样器请求生成多个登录用户 - How to generate multiple login user in jmeter for java sampler request 如何扩展Jmeter Http Sampler在请求中注入auth令牌? - How to extend Jmeter Http Sampler to inject auth token in request? 在JMeter Java API中,如何在PreProcessor采样器中设置POST表单值? - In JMeter java api how to set POST Form values in a PreProcessor sampler? 如何为Jmeter Junit采样器创建更详细的结果消息 - How do I create more verbose result messaging for a Jmeter Junit Sampler 如何在 Jmeter 中使用 TCP 采样器 - How to use TCP sampler in Jmeter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM