Forum Discussion

Hazey's avatar
Hazey
Occasional Contributor
9 years ago
Solved

Parameterizing REST request from TestComplete

As part of my TestComplete test suite, I want to be able to make REST requests to avoid unecessary UI interaction. I have managed to get a REST request working using the SOAPUI intergration. However what I want to be able to do is pass values to this REST request from the tests in TestComplete. 

 

As an example I have the following json in the body of a SOAPUI REST request:

 

{"username":"${#Project#username}","password":"${#Project#password}"}

 

This allows me to change the project properties for the username and password that will be used as part of the login request. In TestComplete I can then change the project properties of the API call once I have added it to the TestComplete project. Ideally I don't want to have to set these as project properties in order to change their value. I want to be able to take values from the output of a keyword test or script, and use those values in the REST request when it makes the call. Is this possible and what is the best approach for this? 

  • Hi,

     

    Did I get you right that you are using SoapUI integration in your TestComplete project, execute some SoapUI test from within your TestComplete test and want to pass parameters from TestComplete test to SoapUI one?

    If the above is correct, than that close integration is not supported by TestComplete (yet?). I think that the only posible approach in this case is to store parameters in some intermediate file in TestComplete test and read the content of this file and assign the proper values to the relevant variables in SoapUI. To implement this in SoapUI, you may either create a startup script or add an additional step to the test.

     

    P.S. Alternative approach is to send REST request directly from TestComplete test (using, for example, http://community.smartbear.com/t5/Functional-Web-Testing/TestComplete-support-for-automating-REST-API/td-p/110066 thread as a sample).

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Did I get you right that you are using SoapUI integration in your TestComplete project, execute some SoapUI test from within your TestComplete test and want to pass parameters from TestComplete test to SoapUI one?

    If the above is correct, than that close integration is not supported by TestComplete (yet?). I think that the only posible approach in this case is to store parameters in some intermediate file in TestComplete test and read the content of this file and assign the proper values to the relevant variables in SoapUI. To implement this in SoapUI, you may either create a startup script or add an additional step to the test.

     

    P.S. Alternative approach is to send REST request directly from TestComplete test (using, for example, http://community.smartbear.com/t5/Functional-Web-Testing/TestComplete-support-for-automating-REST-API/td-p/110066 thread as a sample).

    • Hazey's avatar
      Hazey
      Occasional Contributor

      Thanks for the respone. You did understand correctly what I wanted to pass parameters to SOAPUI tests from within TestComplete, but looks like something that isn't possible, or at least not straight forward to do.

       

      Looking at the link you provided it seems an alternative is to use script to directly make rest requests from within TestComplete. I have tried this using python script, and whilst it seems to work, the import part of the script to import some python libraries is very slow. It takes a few minutes just to import the liburl.request library. I'm not sure if this is an issue with TestComplete or something I don't have setup right.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > I'm not sure if this is an issue with TestComplete or something I don't have setup right.

        I'm not using Python, so cannot comment on this. Just two small notes:

        a) TestComplete 'precompiles' test code on test start, so if your test suite is large (a lot of projects with/or a lot of script units (of large size)) this might result in the noticable start delay;

        b) In any case you may raise a Support request via http://support.smartbear.com/message/?prod=TestComplete form and ask for their comments.