How to get id string from URL


I am looking to pull a numeric string Id out of a URL after the page loads. Im not quite sure how to leverage Katalon to do this.

Example: www.somegreatwebsite/yourstate/123456678645/

Any feedback is greatly appreciated.

Please try the following test case. You should be able to modify this so that it applies to your target url.

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIdef url = ''WebUI.openBrowser('')WebUI.navigateToUrl(url)String currentUrl = WebUI.getUrl()String[] urlComponents = currentUrl.split('/')StringBuilder sb = new StringBuilder()for (int i = 0; i < urlComponents.length; i++) {    sb.append("${i}: \'${urlComponents[i]}\'\n")	}WebUI.comment(sb.toString())WebUI.comment("region code: ${urlComponents[5]}")WebUI.closeBrowser()
1 Like

Worked perfectly with a bit of tweaking. Thank you!