We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
In that case, I would suggest the following:
Have the original file with data as below which uses property expansion as mentioned earlier, you may call it template request.
<abc-request client-application-id="JUnit client" client-domain="JUnit client Domain">
<payload>
<modify-UG>
<charging-id type="msisdn">${#TestCase#MSISDN}</charging-id>
</modify-UG>
</payload>
</abc-request>
Before your json step, have a groovy step which does the transformation of the data and saves into a file in the temporary directory by replacing the MSISDN value.
This way, we always only read the template file(remains same) and create a new temporary file and that is sent as attachment each time. So, no overwriting of that template file.
def tmp = System.getProperty('java.io.tmpdir')
context.testCase.setPropertyValue('FINAL_DIR', tmp)
def originalFilePath = context.expand('${#TestCase#ORIGINAL_FILE_PATH}')
def fileName = context.expand('${#TestCase#FINAL_FILE}')
def content = new File(originalFilePath).text
new File("${tmp}/${fileName}").write(context.expand(content))
Note: If you are using ReadyAPI, then you may avoid additional groovy step, instead use Events feature, TestStep.beforeSubmit and have the above script in it
In the attachment, you define the custom properties as below:
Hi @nmrao,
Attached screenshot here.
Just Brief requirement:
1. In parameterised external request.xml file, there will be request.
2. I have to pass request using file.
3. And while sending request from file,needs to expand custom properties values.
By the way, I would really like to say Thanks for your help and prompt responsiveness. This is really great help
Regards
Vishal Pachpute
In that case, I would suggest the following:
Have the original file with data as below which uses property expansion as mentioned earlier, you may call it template request.
<abc-request client-application-id="JUnit client" client-domain="JUnit client Domain">
<payload>
<modify-UG>
<charging-id type="msisdn">${#TestCase#MSISDN}</charging-id>
</modify-UG>
</payload>
</abc-request>
Before your json step, have a groovy step which does the transformation of the data and saves into a file in the temporary directory by replacing the MSISDN value.
This way, we always only read the template file(remains same) and create a new temporary file and that is sent as attachment each time. So, no overwriting of that template file.
def tmp = System.getProperty('java.io.tmpdir')
context.testCase.setPropertyValue('FINAL_DIR', tmp)
def originalFilePath = context.expand('${#TestCase#ORIGINAL_FILE_PATH}')
def fileName = context.expand('${#TestCase#FINAL_FILE}')
def content = new File(originalFilePath).text
new File("${tmp}/${fileName}").write(context.expand(content))
Note: If you are using ReadyAPI, then you may avoid additional groovy step, instead use Events feature, TestStep.beforeSubmit and have the above script in it
In the attachment, you define the custom properties as below: