[英]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 最佳电视
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.