0
votes

I have integrated selenium code with JMeter using JUnit request sampler. I want to navigate to a URL which I will get from an API response. For this, I can pass a runtime value (URL) to the JUnit jar file. To achieve this, I need to pass response of an API to the JUnit sampler. How can we do this?

2

2 Answers

1
votes
  1. You can extract the "interesting" value using any suitable JMeter PostProcessor and store it into JMeter Variable
  2. The variable can be used in the JUnit Request sampler like:

    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


In the majority of cases it's easier to go for WebDriver Sampler in order to get Selenium integration

1
votes

you can add a "Regular Expression Extractor" to your API-Sampler to get the necessary string from the response. The extracted string can be used by ${ReferenceName}.

Hope this is what you are looking for.

Best tifi