Forum Discussion

rec3's avatar
rec3
Occasional Contributor
5 years ago

API call in test | aqHttp | Request Library | Test Complete | External Python Libraries

I want to make a http request but the Test Complete module aqHttp does not provide the features I need. Certain feature I am looking for are allow_redirect, verify_certificate, and so on. The python ...
  • rec3's avatar
    5 years ago

    I found a work around although it is not desirable. It seems that the subprocess libary work in Test Complete. This will allow you to run program from cmd. This means that you can run python scripts with regular Python not test complete Python and capture the output of these programs. Code will be displayed below.

    testcompletescript.py:

    import sys
    sys.path.insert(0, 'C:\Python36\Lib\site-packages')
    import subprocess
    
    
    def testing123():
     testing = subprocess.getoutput("path\\to\\external\\script\\externalscript.py")
     Log.Message("output", str(testing))

    externalscript.py:

    import requests
    
    
    def testing123():
        response = requests.get("https://www.google.com")
        print(response.content)
    
    testing123()