Is there a way to override the KeyWordUtil Log generated by the WebUI method?

Hello,

I was wondering if it’s possible to override the logs generated by the WebUI method such as :

All options with value ‘XXXX’ are selected in object ''XXX"

I would like to override them in order to have a custom message :slight_smile:

Thanks in advance,

Are you certain you need to override KeywordUtil?

I use KeywordUtil.markWarning() to write custom messages…

KeywordUtil.markWarning(SPACES + msg)

SPACES is globally defined to give me indentation.

1 Like

I woul like to override messages which are generated in those kind of context :

Since I don’t use the Object Repository from Katalon but this :

public static TestObject getMyTestObject(String selectorType, String selectorValue) {
	TestObject to = new TestObject()
	to.addProperty(selectorType, ConditionType.EQUALS, selectorValue)
	return to
}

It’s not display as correctly as with the usual findTestObject. So I want to customize it to have my own log.

public static TestObject getMyTestObject(String selectorType, String selectorValue) { 
  KeywordUtil.markWarning("Create TO for " + selectorValue)
  TestObject to = new TestObject() 
  to.addProperty(selectorType, ConditionType.EQUALS, selectorValue) 
  KeywordUtil.markWarning("TO created for " + selectorValue)
  return to
}
1 Like

I always do the same as you, but a bit differently. How about changing your code:

public static TestObject getMyTestObject(String selectorType, String selectorValue) {
	TestObject to = new TestObject(selectorValue)
        ...

Please note that a meaningful string as an identifier (selectorValue above) is given as the 1st argument to the constructor of new TestObject(...) rather than leaving it unspecified.

See the javadoc of TestObject class and find it has 2 constructor signature; one has an String argument named objectId, another has no argument.

Then You will see messages like this:

16:13:19.039   PASSED  Object: '//a[@id="main_button"]' is clicked on

This message looks fine to me, at least not ugly as “object: '' is clicked on”.

I suppose, you would not be tempted to do any overkilling hacks (overriding the KeywordUtil class).

2 Likes

Thanks a lot @Russ_Thomas and @kazurayam :slight_smile: I will use your solution kazurayam wichh is exactly what I want :+1:

However I do am tempted by overriding the KeywordUtil class haha :grinning:. I have read one of your post about a highlighting feature you developed and the metaprogramming in it, and actually I’m quite interrested. So when I have the time, I’ll read the groovy doc about meta programming. It seems really interesting :slight_smile:

Now I know you had a look at this:

Let me show you another example of my Meta-programming hack, which (I believe) extends the capability of Katalon Studio significantly. See

My com.kazurayam.ks.globalvariable.GlobalVariableAnnex class employs Groovy’s Meta-programming technique to modify the internal.GlobalVariable object runtime. GlobalVariableAnnex can add new properties into the GlobalVariable instance.

This mean that you can add GlobalVariables programmatically while a Test Case is running.

1 Like