Ask a Question

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

SOLVED
rec3
Occasional Contributor

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 libary requests does have all these feature. I imported this libary in the manner suggestion by the community while double checking I have the same python version install globally as Test Complete (Python 3.6). 

sys.path.insert(0, 'C:\\Python36\\Lib\\site-packages')
import requests

def Testing123():
response = requests.get("https://www.example.com", verify=False)
if(response.status_code == 200):
Log.Message("All is good!")

 The libary loads and all seems good but when I run the the function a second time all if Test Complete crashes. This kind of unpredictable behavior is constant when using these 3rd party libaries which are nessessary some of the more complicated tests. Does anyone have an tips?

1 ACCEPTED SOLUTION

Accepted Solutions
rec3
Occasional Contributor

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

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

 

View solution in original post

5 REPLIES 5
rec3
Occasional Contributor

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

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

 

View solution in original post

Marsha_R
Community Hero

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

For problems resulting in crashes, you should contact Support directly.  Here's the link:

https://support.smartbear.com/testcomplete/

sonya_m
Community Manager

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

@rec3 , just an addition to what Marsha said - please use the Report Generator tool to get the crash reports when raising a ticket with the Support Team. This should make the investigaion easier.

 

Also, do share the results of the investigation with usSmiley Happy


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
rec3
Occasional Contributor

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

Hi. I have opened a support ticket and yesterday and spoke to a Smart Bear employee. If there is any relivent information I will relay it here.

TanyaYatskovska
Community Manager

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

Thanks for your investigation, @rec3!

Let me mark your workaround as a solution temporarily. Once you find a better solution, please post it here.

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: