Creating Test Session using WebServices
Hi,
I was doing some Python based automation of Testcase management and was able to modify test results using SOAP web service calls. Working sample code is pasted below, all you need to provide is proper credentials and change ids in testcases dictionary in python code as per your setup.
The only problem is you have to start test session manually before, so that these soap calls can work.
Is there any soap api to start/end test session? Code sample in any language will also help a lot?
Thanks,
Ashish
import requests
import base64
from zeep import Client
from zeep.transports import Transport
session = requests.Session()
username = "<your_ptc_login_name>"
password = "<your_ptc_login_passwd>"
client = Client('http://<PTC Server IP>:7001/webservices/10/Test/Schema?WSDL',
transport=Transport(session=session))
try:
session_id = 494547
client = Client('http://<PTC Server IP>:7001/webservices/10/Test/Schema?WSDL',
transport=Transport(session=session))
test_cases = {"494537": "PASSED", "494539": "PASSED", "494541": "PASSED",
"494543": "FAILED", "494545": "PASSED"}
print(" ============== EDITING RESULTS ================ ")
for tc, results in test_cases.items():
result = client.service.editResults(
arg0={"Username": username, "Password": password,
"SessionID": session_id, "Verdict": results, "Overwrite": True,
"TestCaseID": int(tc)})
print("Setting ", tc , "result: ", results)
print(" ============== GETTING RESULTS ================ ")
for tc in test_cases:
result = client.service.getResults(
arg0={"Username": username, "Password": password,
"Selections": {"TestCase": int(tc)}})
print(result["Result"][0]["TestCaseID"], result["Result"][0]["Verdict"])
except Exception as e:
print(e.args)

