[WS] Send Request And Verify
Description
sendRequestAndVerify(RequestObject request, FailureHandling flowControl)
Send an HTTP request to a web server and verify its response.
Parameters
Parameters | Parameter type | Mandatory | Description |
---|---|---|---|
response | RequestObject | Required | The object that represents an HTTP response. |
Returns
Parameter type | Description |
---|---|
ResponseObject | A response object |
Example
Given the following sample POST a new user
POST request. We have added some verification codes to verify the response in the Verification
tab of the request.
Next, we want to send the request and verify its response. We use the
WS.sendRequestAndVerify
keyword as follows:import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
'Send a POST request and verify its response'
response = WS.sendRequestAndVerify(findTestObject('POST a new user'))
The keyword sends the request and verifies its response using the verification code in the Verification
tab of the request object. You can see the Verification
step the Log Viewer
as follows: