How to get attribute value from page url?

I have a current page url of my project. From that url I want to get one of the value of a attribute. How is it possible?

Hi,

You can use the WebUI.getUrl() method to get the current url open in the browser. And store it in a String variable. Then you can split based on token to get the attribute value.

Can you share a sample url?

Hi Neethu,

for getting current URL, you can use WebUI.getURL()

For parsing and getting URL parameters, following code can be used:

String url = "http://www.dummy.com/params?field1=value1&field2=value2&field3=value3"String getQueryString = url.split("\\?")[1]String[] getFields = getQueryString.split("&")Map<String, String> fieldValueMap = new HashMap<String, String>()for(String field : getFields) {	fieldValueMap.put(field.split("=")[0], field.split("=")[1])}println fieldValueMap.get("field3")
1 Like