# Calling Keyword from another Keyword not working good (Steps & Substeps)

**URL:** <https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [July 12, 2021, 10:24am UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536 "2021-07-12T10:24:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 12, 2021, 10:24am UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/1 "2021-07-12T10:24:57Z")

</div>

Hi,  
I created few custom Keywords, but I am not using them directly in my TestCase, but rather in some other methods, because I am using PageObjectModel.  
So for example I am using my custom keywords let’s say SetDate() and CheckMessages() in let’s say Page\_Register.RegisterNewUser() method and from withing my TestCase, I call only this registerNewUser() method.

But there are 2 problems:

1. In LogViewer, I see only that registerNewUser() step, but I would like to also see those substeps SetDate() and CheckMessages() under that step, and those substeps should display if I expand that step using that expanding arrow. Is there any way, how can I achieve this?

2. In that step, I can’ call CustomKeywords.something, because it’s not possible and shows an error. I can call my keywords directly like a method, but I think Katalon will then see it only as normal function and not as keyword, beacuse when some of these substeps fails (either using KeywordUtil.markFailed or by throwing an exception), step is still shown as passed instead of failed.

So is it possible to implement this Step-Substeps pattern, or it’s just intended to use custom Keywords directly in TestCase?

Thanks so much !!!

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 12, 2021, 12:18pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/2 "2021-07-12T12:18:19Z")

</div>

> [@peter.hevesi](#):
>
> 1. In LogViewer, I see only that registerNewUser() step, but I would like to also see those substeps SetDate() and CheckMessages() under that step,

~~Yes, of course, you can do it.~~ _(edited 13/Jul) Could you show us your code of your custom keyword? I do not see how the 3 names (`registerNewUser`, `SetDate` and `CheckMessages`) relates each other._

> [@peter.hevesi](#):
>
> and those substeps should display if I expand that step using that expanding arrow.

(edited 13/July)

I am not sure what “substeps” you mean.

Let me assume, your test case has a line like:

```auto
CustomeKeyword."my.brilliant.POMClass.registerNewUser"("something")

```

By this line, the Test Case Executer (a part of Katalon Studio) is informed that the `registerNewUser` method of POMClass was executed. It will display in the LogViewer a single line of step execution saying “Test Case Executor executed the registerNewUser() method of the POMClass object”.

The `registerNewUser` method may call other methods in the POMClass : `foo()` and `bar()`. But the method implementation hidden inside the POMClass class. This detail is not exposed to the Test Case Executor. The Test Case Executor does not know anything about `foo()` and `bar()`. Therefore in the LogView we will not see the Step Execution log of `foo` and `bar` at all.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 12, 2021, 12:34pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/3 "2021-07-12T12:34:15Z")

</div>

> [@peter.hevesi](#):
>
> 1. In that step, I can’ call CustomKeywords.something, because …

I do not see what you mean at all.

Please ask a question presenting your code (both of you Test Cases and Keywords). Then we may understand your issue better.

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 12, 2021, 12:43pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/4 "2021-07-12T12:43:41Z")

</div>

Thanks for your quick reply 🙂

Ok, I don’t need to see substeps in LogViewer, but it would be awesome, if I could.

But what is absolutely crucial, is to be able to have that step failed, when some of those substeps failed.  
If it is possible to do it, would you please show me?  
I tried both KeywordUtil.markFailed() method and throwing Exception in those substeps, but my main step still shows as passed, which is extremely strange, because Katalon Studio absolutely should mark step as failed, when there is uncaught exception anywhere in execution. Alsowherever I write KeywordUtil.markFailed() (in any of substeps or even substeps of substeps), it should mean, that the most parent Step is failed.

I also tried to mark the most parent Step as Keyword, and all Substeps are also marked as keyword, but still not working…

I started to use Katalon Studio like a month ago and I am still just trying to solve many problems it has 😃 I wonder, how is it possible, that fundamental problems like I have are still not solved 😃

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 12, 2021, 12:50pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/5 "2021-07-12T12:50:50Z")

</div>

> [@peter.hevesi](#):
>
> KeywordUtil.markFailed()

Do you mean, you use “KeywordUtil.markFailed” inside your Custom Keyword’s implementation?

~~Probably it would not work (or work strange), as “KeywordUtil” is supposed to be used in Test Case scripts, not inside Custom Keywords. Though I have never tried it personally — as I doubt it.~~  
_(edit 13/Jul) I was wrong. “KeywordUtil” is supposed to be used in classes as Custom Keywords. And I do use it as well. Calling KeywordUtil.markFailed() throws a [StepFailedException](https://docs.katalon.com/javadoc/com/kms/katalon/core/exception/StepFailedException.html)._

~~You can make it simple. Why not you write your Custom keyword class to throw some Exception? such as `IllegalArgumentException`, `IllegalStateException`, `IOException`, `MyOwnCustomException`, etc.~~

~~Assuming your Custom Keyword is designed to throw some Exception, you want to write your Test Case like this:~~

```auto
try {
    CustomKeywords."my.brilliant.POMClass.RegisterNewUser"("something")
} catch (Exception e) {
    KeywordUtil.markFailedAndStop("the end of the world")
}

```

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 12, 2021, 1:23pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/6 "2021-07-12T13:23:17Z")

</div>

Yes, I used it inside Custom Keyword’s implementation, because that’s what docs says:  
(“Mark a keyword to be failed and continue execution”)  
[https://docs.katalon.com/javadoc/com/kms/katalon/core/util/KeywordUtil.html](https://docs.katalon.com/javadoc/com/kms/katalon/core/util/KeywordUtil.html)  
So I am now very confused, when you said, it is supposed to be used inside TestCase. If you are right, then the documentation is dumb. even the name KeywordUtil totally suggest, that this class should be used inside Custom Keyword’s implementation 😃  
Are you sure in what you are saying?

I tried to throw exception, and it marks whole TestCase as failed, but marks my Step (my custom Keyword) as passed, even if it throws exception.

To be honest, I sometimes wonder, what were the thoughts of Katalon Developers, when they were implementing this. There is no way how you can do this Steps-Substeps pattern, which is absolutely logical way of doing it, even they implemented it in their custom keywords, that’s why sometimes, you can expand step in LogViewer and see substeps, but it’s not possible to do it in my own keywords?  
And how come throwing an exception won’t mark that step as failed? That’s totally weird and I read many other posts, where people had a problem with this, that Step, or even whole TestCase is marked as passed, even though it definitely should be marked as failed. Even writing “assert something” won’t make TestCase failed…

Like almost nothing seems to be working in a good way here in Katalon Studio, I start to be demotivated…  
When you want to use data binding, it’s binding everything as a String, so I had to create my own workaround to be able to use something else, than just a String…

> [@Perfect Data Binding Workaround, Which Allows To Work With Any Data Easily](http://forum.katalon.com/t/perfect-data-binding-workaround-which-allows-to-work-with-any-data-easily/56247/3):
>
> I UPDATED IT EVEN MORE rofl I discovered, that there is @BeforeTestDataBindToTestCase method in TestListener. So here is my TestListener now: [image] But be aware, that this method @BeforeTestDataBindToTestCase will run only if you run or debug your TestCase from TestSuite. If you run or debug just a single TestCase, this method won’t run at all… And here is updated data file: [Data.zip](https://forum.katalon.com/uploads/short-url/xJoILoQD2h1i7wlfv8985wdAC4A.zip) (2.4 KB) Now you don’t need to put anything to global variables, and you can use your variables in Tes…

How come you guys use Katalon Studio, when it has so many problems? 😃

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 12, 2021, 2:24pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/7 "2021-07-12T14:24:59Z")

</div>

> [@peter.hevesi](#):
>
> There is no way how you can do this Steps-Substeps pattern, which is …

Sorry, still I do not understand what you call _“Steps-Substeps pattern”_. Could you make a small runnable project which demonstrates your arguments, and disclose it here by attaching the zip of the project? Also could you give us descriptions how weird you think the demo project is, with reference to the concrete code?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [July 12, 2021, 2:58pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/8 "2021-07-12T14:58:45Z")

</div>

> [@peter.hevesi](#):
>
> Yes, I used it inside Custom Keyword’s implementation, because that’s what docs says:  
> (“Mark a keyword to be failed and continue execution”)  
> [https://docs.katalon.com/javadoc/com/kms/katalon/core/util/KeywordUtil.html](https://docs.katalon.com/javadoc/com/kms/katalon/core/util/KeywordUtil.html)  
> So I am now very confused, when you said, it is supposed to be used inside TestCase. If you are right, then the documentation is dumb. even the name KeywordUtil totally suggest, that this class should be used inside Custom Keyword’s implementation 😃  
> Are you sure in what you are saying?

Both @kazurayam and I are experienced KS users but I think it’s fair to say, we tend to approach Katalon differently and, therefore, sometimes differ on how a particular API is intended to be used.

For me, markFailed is most definitely of use inside Keyword classes/methods. I did a search in my classes and found it’s being used 104 times.

Even so, that does not mean I can promise you an outcome you would like. My testing philosophy and approach are likely very different to yours - my POM takes advantage of my own test case executor developed over a number of years.

That said, here’s how my Test Case philosophy works from a high level overview:

1. I don’t care about passes. I don’t log them, I don’t keep them, I don’t add them to reports. PASSES == NOISE.

2. I write my own messages to the log using WARNINGs – `KeywordUtil.markWarning()`. These messages are “steps” passed to the Report subsystem.

3. For failures I also throw a StepErrorException – this is the point at which my code exits to the native Katalon executor.

You can see some of the internals here in this screenshot:

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/f/e/fefd3598440776e5da025eabe693a6fbcf8a33f9.png)

I repeat - I don’t expect you to glean much from this. I certainly could not throw a few lines of code at you and suddenly you have things working just as you would like. But what I am saying is, _you can develop a satisfactory system if you are prepared to put the work in_. It’s just “java and groovy” and, as @kazurayam would attest, if you don’t like how Katalon does something, you can hijack the internals and make it work your way, if that’s what you want.

Good luck.

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 8:05am UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/10 "2021-07-26T08:05:02Z")

</div>

Thanks for your reply 🙂

You mentioned few things that are very important for me:

1. You created your own TestExecutor - can you please tell me, how I can also implement my own TestExecutor? Or maybe even share your TestExecutor implementation with me?

2. “You can hijack the internals” - Can you please show me how can I work with Katalon internals?

Thanks so much !!! 🙂

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 9:40am UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/11 "2021-07-26T09:40:09Z")

</div>

> [@peter.hevesi](#):
>
> can you please tell me, how I can also implement my own TestExecutor?

You can read the source code of the [`com.kms.katalon.core.main.TestCaseExecutor`](https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/main/TestCaseExecutor.java). You can read it. You can find other sources in [the repository](https://github.com/katalon-studio/katalon-studio-testing-framework), where they disclose the some portion of their product (not entirely).

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 10:01am UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/12 "2021-07-26T10:01:19Z")

</div>

Thanks soooooo much, you helped me a lot 🙂

But still, how you hijack those internals? How to make Katalon Studio work with any of my modifications?  
How you made your TestCaseExecutor work with Katalon Studio?

Do you create a plugin to use your own TestCaseExecutor?

And also, the code in that repository [https://github.com/katalon-studio/katalon-studio-testing-framework](https://github.com/katalon-studio/katalon-studio-testing-framework)  
is probably already outdated, so when I make my modifications, it might not work correctly with the rest of the system. So I am curious how exactly you did it 😃

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 1:03pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/13 "2021-07-26T13:03:33Z")

</div>

> [@peter.hevesi](#):
>
> But still, how you hijack those internals?

You have a misunderstanding. It is @Russ_Thomas who wrote _“you can hijack the internals”_, not me @kazurayam. I just pointed you to the URL of Katalon source codes.

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 1:05pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/14 "2021-07-26T13:05:33Z")

</div>

Aha sorry, my bad 😃

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 1:06pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/15 "2021-07-26T13:06:24Z")

</div>

> [@peter.hevesi](#):
>
> And also, the code in that repository [https://github.com/katalon-studio/katalon-studio-testing-framework](https://github.com/katalon-studio/katalon-studio-testing-framework)  
> is probably already outdated

Yes, you can easily find that the repository was last updated at Dec, 2020.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 1:10pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/16 "2021-07-26T13:10:43Z")

</div>

> [@peter.hevesi](#):
>
> so when I make my modifications, it might not work correctly with the rest of the system.

You are theoretically correct.

But I believe that the `com.kms.katalon.core.main.TestCaseExecutor` in the ver 8.1.0 would stay the same as the Dec 2020 version. So practically the Dec 2020 source code would be good enough to learn the internal of Katalon Studio.

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 1:14pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/17 "2021-07-26T13:14:15Z")

</div>

Ok, thank you for your help, I appreciate it very much 🙂 ❤

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 1:18pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/18 "2021-07-26T13:18:22Z")

</div>

Just for your information, let me introduce one of my artifacts (published 2 years and 6 months ago) to you.

> [@HighlightElement keyword makes your presentation more attractive](http://forum.katalon.com/t/highlightelement-keyword-makes-your-presentation-more-attractive/17549):
>
> Please have a look at this video first: [https://kazurayam.github.io/HighlightingElementByTestObjectInEachAndEveryStep/](https://kazurayam.github.io/HighlightingElementByTestObjectInEachAndEveryStep/) Do you like the red dotted outline on HTML element? It is drawn by a custom keyword HightlightElement. This would make your presentations and demos at Meet-up events more attractive for your audiences. See [How to Highlight Test object in each and every step - #6 by kazurayam](http://forum.katalon.com/t/how-to-highlight-test-object-in-each-and-every-step/17408/6) for detail

This artifact shows **how I dynamically modified the internal of Katalon Studio** using Groovy’s Metaprogramming technique.

I do not understand what you @peter.hevesi want to do, so I am not sure if this artifact is informative for you. May be not.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [July 26, 2021, 1:33pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/19 "2021-07-26T13:33:28Z")

</div>

> [@kazurayam](#):
>
> This artifact shows **how I dynamically modified the internal of Katalon Studio** using Groovy’s Metaprogramming technique.

I used the Groovy’s metaprogramming techinque in my Keyword class implementation. The class is invoked by the TestExecutor built-in Katalon Studio. Here comes a timing issue. Since the built-in TestExecutor object is already instantiated and in action, any Metaprogramming done by a TestCase (+custom keyword class) in action will never be able to modify the TestExecutor instance.

So, I believe, my article is NOT informative for you @peter.hevesi

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 1:34pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/20 "2021-07-26T13:34:16Z")

</div>

It is totally informative, I can’ thank you enough 😃  
There is no doubt we should call you Katalon King 😃 🙂

Aha, you just wrote, that I can’t replace that instance 😃  
Nevermind, maybe it won’t help me in what I am trying to achieve, but still I am very glad that you sent me that project 🙂

---

<div class="post-metadata">

**Author:** ![peter.hevesi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/peter.hevesi/32/17756_2.png) [@peter.hevesi](https://forum.katalon.com/u/peter.hevesi)\
**Post date:** [July 26, 2021, 1:55pm UTC](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536/21 "2021-07-26T13:55:37Z")

</div>

> [@kazurayam](#):
>
> instantiated

But actually, what you are saying is, that I can’t replace TestExecutor from TestCase, because it is already created and running, but I probably should replace it from TestListener?  
All I want to do is to modify the behavior of “logging and reporting” so to say and I want to do it gloabaly for each TestCase, so I actually think I may be able to do it 😃

[Next page](https://forum.katalon.com/t/calling-keyword-from-another-keyword-not-working-good-steps-substeps/56536.md?page=2)
