I need to fire some API request to a particular server and extract some generated document path from the server response along with the regular functional testing testcases.
Can someone please guide me if this is achievable or not?
It seems achievable but your description is not concrete enough.
Please show what you have done — the Test Case script that you have made. If you have any error log message, please show it as well. The codes will explain to others what you need to know more.
Have you made a script that does this? Can you share it?
Have you managed to do this, or not?
What do you mean by this? Any sample code?
This is what i need to achieve through katalon-
Posting XML Request to a Server and extract document path from the Response.
You want to send a HTTP request to some API Server. Then you need to understand how to make Test Object for API. You need to read the docs starting with:
You should be able to create a Test Object that carries a XML document in the HTTP Body. That would be something like this:
Please, at first, make a TestObject that can successfully receive a HTTP response with meaningful XML document.
How to parse the XML and extract data — that would be a question to be addressed later.
I was able to create an API object and the request ran successfully. Now my next point is how to call out/execute/trigger this in a normal test script. Can it run automatically without clicking on the play button.
I suppose you want to create a Test Case script that use the TestObject so that it can make HTTP Request and receive a HTTP Response. There are many examples published by Katalon. For example,
Have a look at the sample codes and try running it. You would be able to mimic them to create a Test Case for your case.
I am not sure what you mean.
If you want to run the test in the Command Line interface as a part of your CI/CD pipleline rather than playing on the GUI, then you need to purchase a license of Katalon Runtime Engine.
Yes,i want to use this Api object in a normal Test case and need to get this object executed at Test Case.So just wanted to know if there is any keyword to execute this Api object in a Test Case.
Hello , to answer your question , API and WebUi test scenarios can be called or used in a single test script
create any test case and lets assume you want to send a request (API created in object repository) and then use a webui step.
1- Use the Webservice keyword and select sendrequest and use the API that you created in Object repository
2- Use any WebUI keyword to perform any scenario
Let me answer to your question by example.
I made a Test Object with id “Object Repository/SearchGoogle”.
I made a Test Case with the script as follows:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/**
* A demo how to use Google Custom Search JSON API
* https://developers.google.com/custom-search/v1/overview
*/
def response = WS.sendRequestAndVerify(findTestObject("Object Repository/SearchGoogle", [:]))
println JsonOutput.prettyPrint (response.getResponseText())
JsonSlurper jsonSlurper = new JsonSlurper()
def jsonResponse = jsonSlurper.parseText(response.getResponseText())
println "-----------------------------------------------------------"
println jsonResponse.kind
println jsonResponse.url.type
println jsonResponse.url.template
println jsonResponse.queries.request[0].searchTerms
println jsonResponse.queries.request[0].count
Please find here a call to WS.sendRequest
keyword which takes a Test Object as parameter. That’s what you want.
Thanks @Monty_Bagati.This is what I was looking for.