26.21 Using OpKey APIs to get execution result in json
Overview
An application program interface (API) is a set of subroutine definitions, communication protocols that allow two software programs to communicate with each other. There are few new APIs in the OpKey which allows OpKey users to get the execution result of their executed Test Cases and without accessing OpKey directly by using API Tools like Postman & SoapUI.
OpKey users can now use OpKey APIs to get the execution result of Test Case and Suites without directly accessing the OpKey Web user interface.
The Need of OpKey APIs
APIs work as a bridge of communication between two applications over a network. If an OpKey user wants to get details of the execution result of Test Cases and Suites then he/she can use these APIs with an API Tool like Postman & SoapUI. These APIs are
- Authorize
- GetSuiteResult
- GetTestCaseResult
Getting started with OpKey APIs
Let us start using the OpKey APIs on Postman API Tool to get the execution result details about the executed Test Case and Suites. An API URI composed of URL (OpKey Web domain URL), with Resource Path & Query Parameter i.e.
API URI = URL + Resource_Path + Query_Parameter
Note: Some API URIs don’t contain Query Parameters.
(1) Authorize
This API is used to get the Authorization Token by using the Username and Password of OpKey Web using the POST method.
If OpKey Web domain URL is http://www.xyz.myopkey.com then…
- API URI (Variable): http://www.xyz.myopkey.com/api/OpkeyAuth/authorize
- Resource Path (Static): /api/OpkeyAuth/authorize
- There is no Query Parameter
Note: Here, the API URI depends on the OpKey Web domain name.
- Select the Post Method and enter the API URL, go to the Authorization tab and enter OpKey Username and Password and then click on Send to get the Authorization Token.
- The Authorization Token has been fetched which can be used in further APIs as input.
(2) GetSuiteResult
This API fetches the details about the execution result of Suite in Json format. This API takes few Query Parameters and Authorization Tokens as input using Get Method.
If OpKey Web domain URL is http://www.xyz.myopkey.com then…
- API URI (Variable): http://www.xyz.myopkey.com/api/OpkeyRestV2/GetSuiteResult?ProjectName=NameOfProject&BuildName=NameOfBuild&SessionName=NameOfExecutionSession
- Resource Path (Static): /api/OpkeyRestV2/GetSuiteResult
- Query Parameter (Variable): ?ProjectName=NameOfProject&BuildName=NameOfBuild&SessionName=NameOfExecutionSession
Note: Here, the API URI and Query Parameters are variable in nature which depend on your Project, Build, Session etc.
- Select the Get Method & enter the API URL, go to the Params tab and enter Query Parameters like ProjectName, BuildName & SessionName.
- Go to the Authorization tab and enter the Authorization Token and then click on Send to run the Get Method and fetch execution result.
- Here, you can have a look at the Suite Execution Result details in Json format under the Body tab.
(3) GetTestCaseResult
This API fetches the details about the execution result of the Test Case in Suite. This API takes few Query Parameters and Authorization Tokens as input using Get Method. You need to run the GetSuiteResult API in order to get the Test Case Step ID which is required as a Query Parameter in this API (GetTestCaseResult) for getting the Test Case Result.
If OpKey Web domain URL is http://www.xyz.myopkeycom then…
- API URI (Variable): http://www.xyz.myopkey.com/api/OpkeyRestV2/GetTestCaseResult?ProjectName=NameOfProject&BuildName=NameOfBuild&SessionName=NameOfExecutionSession&TestCaseStepID=IDOfYourTestCaseStep
- Resource Path (Static): /api/OpkeyRestV2/GetTestCaseResult
- Query Parameter (Variable): ?ProjectName=NameOfProject&BuildName=NameOfBuild&SessionName=NameOfExecutionSession&TestCaseStepID=IDOfYourTestCaseStep
Note: Here, the API URI and Query Parameters are variable in nature which depend on your Project, Build, Session, Test Case Step ID etc.
- Select the Get Method & enter the API URL, go to the Params tab and enter Query Parameters like ProjectName, BuildName, SessionName & TestCaseStepID.
- Go to the Authorization tab and enter the Authorization Token and then click on Send to run the Get Method and fetch execution result.
- Here, you can have a look at the Test Case Execution Result details in Json format under the Body tab.
Thus, you don’t need to access the OpKey Web to get the test case or Suite execution result. You can use these above-mentioned APIs to do get the test case or Suite execution result details.
(4) ALL SESSIONS OF A BUILD
This API is used to get all the sessions of an executed build
API URI (Variable) – https://qa1.stg.smartopkey.com/api/OpkeyRestV2/GetAllSessions?ProjectName=TAG DASHBOARD (Accelerator)&BuildName=LONG EXECUTION
Resource Path (Static) – /api/OpkeyRestV2/GetAllSessions
Query Parameter (Variable) : ?ProjectName=TAG DASHBOARD (Accelerator)&BuildName=LONG EXECUTION
(5) GET ALL SESSIONS OF A PROJECT
This API is used to get all sessions of a project
API URI Variable – https://qa1.stg.smartopkey.com/api/OpkeyRestV2/GetAllBuilds?ProjectName=TAG DASHBOARD (Accelerator)
Resource Path (Static) – /api/OpkeyRestV2/GetAllBuilds
Query Parameter (Variable) – ?ProjectName=TAG DASHBOARD (Accelerator)
(6) GET ALL TAGS OF A SESSION
This API is used to get all tags of a session
API URI – https://qa1.stg.smartopkey.com/api/OpkeyRestV2/GetSessionTags?ProjectName=TAG DASHBOARD (Accelerator)&BuildName=LONG EXECUTION&SessionName=Job 80TCs with 30tags PassFail_2019_Oct_10_08_17_30
Resource Path (Static) – /api/OpkeyRestV2/GetSessionTags
Query Parameter (Variable) – ?ProjectName=TAG DASHBOARD (Accelerator)&BuildName=LONG EXECUTION&SessionName=Job 80TCs with 30tags PassFail_2019_Oct_10_08_17_30