Posts

Showing posts from March, 2025

Script for replace the data into the file content using groovy with jsr223

Image
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()) }

Convert Swagger apis into jmeter script

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