Method #1 1. Download "openapi-generator-cli-7.9.0.jar" from https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/ 2. get the json file from swagger 3. execute the below command in cmd prompt java -jar openapi-generator-cli-7.9.0.jar generate -i sampleAPI.json -g jmeter Note: java should be in env variables and jar be in the same path Method #2 import to Postman and export each API with the curl command copy the curl command and Jmeter->Tools->import from cUrl-> place the command and import. Note: Manual effort and recommended for specific APIs
import java.nio.file.* def usdcor = vars.get('TestData_name') //TestData_name was defined in userdefined or any corralted value log.info("Current Working Directory: " + System.getProperty("user.dir")) // Path to the file to be updated def filePath = "./Scripts/file.txt" // Replace with your file's path // Define the new content def newData = "This is the new content being added./\n asdfasdfasdfasdfsadf" + usdcor try { // Overwrite the file with the new content (clears the old data) Files.write(Paths.get(filePath), newData.getBytes()) log.info("File content replaced successfully!") } catch (Exception e) { log.error("Error while updating the file: " + e.getMessage()) }
sub: one scenario need to capture the data from previous request and pass as a parameters in jmeter Problem: but key and pair both are dynamic and very huge values. we can't handle each parameter as below Note: Here Key and values both are dynamic Solution : we need to capture all the respose data and segrigate and pass through JSR223Preprocessor. Here is the solution. Step1: Step 2: Modify the request Add JSR223Preprocessor in the request //int count=Integer.parseInt(vars.get(“paths_matchNr”)) //log.info “parameters count” + count //vars.put("JsonResponse", prev.getResponseDataAsString()); import java.util.regex.Matcher; import java.util.regex.Pattern; import java.text.*; import java.util.*; //Paths Data List result= new ArrayList(); def count = Integer.parseInt(vars.get("ALLVALUES_matchNr")); log.info("count=" + count);//83 //["#31:218","#62:1","#61:1","#63:1","#31:2...
Comments
Post a Comment