Forum Discussion

deepti11sharma's avatar
deepti11sharma
New Contributor
7 years ago

How to modify existing teststep in SoapUI test suit by reading data from file using java?

I have a scenario where I have a wsdl url.  I have created requests using java soap api and added those request to testsuit as a test Step.

Now I am have another requirement where I have to modify the request generated from wsdl and added to test suit as a test step by reading data from a File. Here is the code snippet.

 

      WsdlOperation op = wsdl.getOperationAt(i);
        System.out.println("op::::::"+op);
        String opName = op.getName();
        System.out.println("OP:"+opName);
        reqContent = op.createRequest(true);
        System.out.println("reqContent:::"+reqContent);
        WsdlRequest req = op.addNewRequest(opName);
        System.out.println("req::::"+opName);
        req.setRequestContent(reqContent);
        TestStepConfig testStep

Config = WsdlTestRequestStepFactory.createConfig(op,opName);
        System.out.println("testStepConfig::"+testStepConfig.getConfig());
        WsdlTestStep testStep=testCase.addTestStep(testStepConfig);

 

 

In rest of the code I am able to get the testSteps from test suits and I am able to read file data using java file API but I am not able to modify the test step data with data read from file.

 

here is the data in the TestStep:-

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:APR>
         <web:LoanAmount>?</web:LoanAmount>
         <web:ExtraCost>?</web:ExtraCost>
         <web:InterestRate>?</web:InterestRate>
         <web:Months>?</web:Months>
      </web:APR>
   </soapenv:Body>
</soapenv:Envelope>

 

Will appreciate If any one can help on this. This is a very urgent requirement from a Client to be implemented ASAP.

 

Thanks!

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    You mean to say that you have a project with test suite -> test cases -> teststeps.

    And you have a request file for a certain test step and you want to update the project with above request from file?
    • deepti11sharma's avatar
      deepti11sharma
      New Contributor

      Thanks rao for replying I figured out solution.

       

      runner.getTestCase().getTestStepByName(newFileName).getProperty("Request").setValue(content);

       

      Here content will be the modified xml you want to save in a request teststep.