Web API integration

Hi Team,

I need help with below mentioned points :

  1. I need to compare web UI data with data rendered from API in a single web automation project of Katalon.

For instance, the data captured from web Ui is ‘abc’ and the corresponding API response is ‘xyz’ then I need to compare ‘abc’ with ‘xyz’.

I need to use rest assured library for API with web automation project.

Please help me with this.

I have already added rest assured jar in project config but not able to import and use it in my test case.

An example of rest assured will greatly help with even simple ‘get’ API call.

hmmm… why exactly you need rest asured when Katalon have Web Services support built in?

Thanks Andrej for your response.

I need to validate whether a API response(json) matches a certain schema(only keys).

Only the schema needs to be verified .

Can you let me know if Katalon has built in support for that ?

Katalon probably not, but there are solutions based on groovy e.g.:


no personal experience on project yet, i just know it exists.

Thanks Andrej .

Just one more thing,can you let me know how to use it in Katalon ?

A small example on any public API would help :slight_smile:

1. install Gradle
2. download sources
3. build

$ gradle test install

4. find builded jar (for me it was c:\Users\andrej\src\groovyschema\build\libs\) since i downloaded sources in c:\Users\andrej\src\groovyschema
5. load jar file from above dir as external lib
6. enjoy

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpointimport static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport static com.kms.katalon.core.testdata.TestDataFactory.findTestDataimport static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport com.kms.katalon.core.checkpoint.Checkpoint as Checkpointimport com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactoryimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywordsimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobileimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.testcase.TestCase as TestCaseimport com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactoryimport com.kms.katalon.core.testdata.TestData as TestDataimport com.kms.katalon.core.testdata.TestDataFactory as TestDataFactoryimport com.kms.katalon.core.testobject.ObjectRepository as ObjectRepositoryimport com.kms.katalon.core.testobject.TestObject as TestObjectimport com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywordsimport com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywordsimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIimport internal.GlobalVariable as GlobalVariableimport groovyschema.Validatordef schema = [	type: 'object',	required: true,	properties: [	  honorificPrefix: [enum:['Ms.', 'Mr.', 'Dr.']],	  givenName: [type:'string', required:true],	  additionalName: [type:'string'],	  familyName: [type:'string', required:true],	  honorificSuffix: [enum:['Ph.D.', 'Esq.']],	  email: [format:'email', required:true],	]  ]jsonText = '{ "honorificPrefix" : "Mr.", "givenName" : "Andrej", "additionalName": "Peter", "familyName": "Podhajsky", "honorificSuffix": "Ph.D.", "email": "apo@hell.org" }'  //jsonText = '{ "honorificPrefix" : "Morron.", "additionalName": "", "honorificSuffix": "", "email": "apo@hell.org" }'  def validator = new groovyschema.Validator()  def instance = new groovy.json.JsonSlurper().parseText(jsonText)    def validationErrors = validator.validate(instance, schema)    println validationErrors

console after execution with correct one:

07-27-2018 12:31:16 AM - [START]  - Start Test Case : Test Cases/New Test Case 107-27-2018 12:31:17 AM - [INFO]   - Evaluating variables for test case07-27-2018 12:31:17 AM - [START]  - Start action : Statement - schema = ["type":"object", "required":true, "properties":["honorificPrefix":["enum":["Ms.", "Mr.", "Dr."]], "givenName":["type":"string", "required":true], "additionalName":["type":"string"], ... ]]07-27-2018 12:31:17 AM - [END]    - End action : Statement - schema = ["type":"object", "required":true, "properties":["honorificPrefix":["enum":["Ms.", "Mr.", "Dr."]], "givenName":["type":"string", "required":true], "additionalName":["type":"string"], ... ]]07-27-2018 12:31:17 AM - [START]  - Start action : Statement - jsonText = "{ "honorificPrefix" : "Mr.", "givenName" : "Andrej", "additionalName": "Peter", "familyName": "Podhajsky", "honorificSuffix": "Ph.D.", "email": "apo@hell.org" }"07-27-2018 12:31:17 AM - [END]    - End action : Statement - jsonText = "{ "honorificPrefix" : "Mr.", "givenName" : "Andrej", "additionalName": "Peter", "familyName": "Podhajsky", "honorificSuffix": "Ph.D.", "email": "apo@hell.org" }"07-27-2018 12:31:17 AM - [START]  - Start action : Statement - validator = new groovyschema.Validator()07-27-2018 12:31:17 AM - [END]    - End action : Statement - validator = new groovyschema.Validator()07-27-2018 12:31:17 AM - [START]  - Start action : Statement - instance = new groovy.json.JsonSlurper().parseText(jsonText)07-27-2018 12:31:17 AM - [END]    - End action : Statement - instance = new groovy.json.JsonSlurper().parseText(jsonText)07-27-2018 12:31:17 AM - [START]  - Start action : Statement - validationErrors = validator.validate(instance, schema)07-27-2018 12:31:17 AM - [END]    - End action : Statement - validationErrors = validator.validate(instance, schema)07-27-2018 12:31:17 AM - [START]  - Start action : Statement - println(validationErrors)[]07-27-2018 12:31:17 AM - [END]    - End action : Statement - println(validationErrors)07-27-2018 12:31:17 AM - [PASSED] - Test Cases/New Test Case 107-27-2018 12:31:17 AM - [END]    - End Test Case : Test Cases/New Test Case 1

bad one:

07-27-2018 12:36:12 AM - [START]  - Start Test Case : Test Cases/New Test Case 107-27-2018 12:36:12 AM - [INFO]   - Evaluating variables for test case07-27-2018 12:36:13 AM - [START]  - Start action : Statement - schema = ["type":"object", "required":true, "properties":["honorificPrefix":["enum":["Ms.", "Mr.", "Dr."]], "givenName":["type":"string", "required":true], "additionalName":["type":"string"], ... ]]07-27-2018 12:36:13 AM - [END]    - End action : Statement - schema = ["type":"object", "required":true, "properties":["honorificPrefix":["enum":["Ms.", "Mr.", "Dr."]], "givenName":["type":"string", "required":true], "additionalName":["type":"string"], ... ]]07-27-2018 12:36:13 AM - [START]  - Start action : Statement - jsonText = "{ "honorificPrefix" : "Morron.", "additionalName": "", "honorificSuffix": "", "email": "apo@hell.org" }"07-27-2018 12:36:13 AM - [END]    - End action : Statement - jsonText = "{ "honorificPrefix" : "Morron.", "additionalName": "", "honorificSuffix": "", "email": "apo@hell.org" }"07-27-2018 12:36:13 AM - [START]  - Start action : Statement - validator = new groovyschema.Validator()07-27-2018 12:36:13 AM - [END]    - End action : Statement - validator = new groovyschema.Validator()07-27-2018 12:36:13 AM - [START]  - Start action : Statement - instance = new groovy.json.JsonSlurper().parseText(jsonText)07-27-2018 12:36:13 AM - [END]    - End action : Statement - instance = new groovy.json.JsonSlurper().parseText(jsonText)07-27-2018 12:36:13 AM - [START]  - Start action : Statement - validationErrors = validator.validate(instance, schema)07-27-2018 12:36:13 AM - [END]    - End action : Statement - validationErrors = validator.validate(instance, schema)07-27-2018 12:36:13 AM - [START]  - Start action : Statement - println(validationErrors)[[instance:Morron., schema:[enum:[Ms., Mr., Dr.]], message:groovyschema.enum.message], [instance:null, schema:[type:string, required:true], message:groovyschema.required.message], [instance:null, schema:[type:string, required:true], message:groovyschema.required.message], [instance:, schema:[enum:[Ph.D., Esq.]], message:groovyschema.enum.message]]07-27-2018 12:36:13 AM - [END]    - End action : Statement - println(validationErrors)07-27-2018 12:36:13 AM - [PASSED] - Test Cases/New Test Case 107-27-2018 12:36:13 AM - [END]    - End Test Case : Test Cases/New Test Case 1