A different solution to get the HTTP Status Code?

Hello everyone,
I want to run a simple test that return the HTTP Status Code of a given page. For now I have the following script:

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

try {
WebUI.navigateToUrl(lien)
} catch(BrowserNotOpenedException) {
WebUI.openBrowser(lien)
}

RequestObject ro = new RequestObject()
ro.setRestRequestMethod("GET")
ro.setRestUrl(lien)
ResponseObject resp = WS.sendRequest(ro)
WS.verifyResponseStatusCode(resp, 200)

WebUI.closeBrowser() 

It works as I except, but I wonder is there is a smarter way to do it? I mean that I want to know if it is mandatory to make a sendRequest() when I have already done a navigateToUrl().

In advance, thanks for you answer :blush:

Hi,

those two requests are different - currently you are not able to get HTTP response from WebUI keywords.

Ok, thank you very much @Marek_Melocik for your answer. I’ll continue with this solution then :wink: