# WebUI Test Object - Best Practice

**URL:** <https://forum.katalon.com/t/webui-test-object-best-practice/67553>\
**Category:** Miscellaneous\
**Tags:** start-page\
**Created:** [August 2, 2022, 12:31pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553 "2022-08-02T12:31:06Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 12:31pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/1 "2022-08-02T12:31:07Z")

</div>

Hi All, we are using katalon as our testing tool since more than 2 years. initially everyone was very new to automation and we relied on record and play approach which resulted in huge test object which are redundant as well as repetitive. Katalon provides a way to delete the unused object but the duplication still remains an issue . can someone suggest some articles or provide links on **Best practices to maintain test object in katalon .** you can share your own view as well. Thanks @katalon.team @Russ_Thomas @kazurayam @ThanhTo

---

<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:** [August 2, 2022, 1:13pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/2 "2022-08-02T13:13:23Z")

</div>

For various reasons, I’m not a fan of the phrase “Best Practice”. So I can’t hand-on-heart tell you what is “best practice”. However…

I never use the Object Repository (OR) – mine is completely empty. If I need a Test Object, I create one, live, in memory, during the test. I use a custom keyword [`makeTO()`](https://docs.katalon.com/docs/katalon-studio-enterprise/test-design/web-test-design/web-test-objects/manage-web-test-objects#creation-of-test-object-in-memory-at-runtime).

Using the Recorder, you’ll have a worthless struggle on your hands trying to maintain a robust and meaningful set of targets. I honestly can’t imagine the pain you go through just to maintain the OR, all before you get to write a line of test case code.

Starting today, rewrite your TOs to use `makeTO()`. Build a Page Object Model (POM) _by hand_ and start testing like a pro. 🕶

> Note. The published copy of `makeTO()` is written to use `css`. You can easily modify it to use xpath by changing “css” to “xpath”, if you wish.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 1:41pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/3 "2022-08-02T13:41:44Z")

</div>

Thank you so much @Russ_Thomas . yeah the struggle is real. our repository takes 15-20 min to load and its not katalon fault. The solution you have suggested is really good. I am not sure how feasible it would be for us to move completely to POM as we already have 15K+ objects residing in our repo. I am afraid that the same thing will continue which will create redundancy and duplication. what would you have done if you were at our place given that we have 15K+ object already and now wanted to somehow streamline the process?

---

<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:** [August 2, 2022, 2:15pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/4 "2022-08-02T14:15:47Z")

</div>

> [@sumiranraut96](#):
>
> we already have 15K+ objects residing in our repo.

😱

 

---

<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:** [August 2, 2022, 2:18pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/5 "2022-08-02T14:18:34Z")

</div>

> [@sumiranraut96](#):
>
> what would you have done

Hard to say because I’m not/ was not in that position. In my early days using Katalon, I very quickly realized the OR doesn’t scale. So I looked into what a TO actually _ **is** _ and decided to roll my own and ditch the OR.

---

<div class="post-metadata">

**Author:** ![anon46315158](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anon46315158](https://forum.katalon.com/u/anon46315158)\
**Post date:** [August 2, 2022, 2:34pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/6 "2022-08-02T14:34:52Z")

</div>

> [@sumiranraut96](#):
>
> can someone suggest some articles or provide links on **Best practices to maintain test object in katalon**

Best practice to maintain test objects is to not use them at all.  
For WebUI testing, follow a POM approach.  
For API testing … yeah, you **may** use such, but keep them as a minimum.  
Use generic ones, parameterized so you can re-use them (e.g one for each http verb).  
You don’t need more than this.

If you will set your mind to design your test-cases in a ‘given - when - then’ structure, even if you don’t actually use the BDD feature, you will figure it out how such can help.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 2:41pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/7 "2022-08-02T14:41:37Z")

</div>

Thanks @anon46315158 for your suggestion. I never worked on selenium so not that much aware about POM on a very detailed level . How to implement POM in katalon ? ([Manage Web Test Objects | Katalon Docs](https://docs.katalon.com/docs/katalon-studio-enterprise/test-design/web-test-design/web-test-objects/manage-web-test-objects#creation-of-test-object-in-memory-at-runtime)) does this method considered as POM. or do we have any other way in which we can implement the POM in katalon ?

---

<div class="post-metadata">

**Author:** ![anon46315158](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anon46315158](https://forum.katalon.com/u/anon46315158)\
**Post date:** [August 2, 2022, 2:44pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/8 "2022-08-02T14:44:45Z")

</div>

> [@sumiranraut96](#):
>
> How to implement POM in katalon

Search the forum and you may be surprised that you can find various approaches and plenty code snippets.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 2:45pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/9 "2022-08-02T14:45:28Z")

</div>

Thanks @anon46315158 . will do

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [August 2, 2022, 3:55pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/10 "2022-08-02T15:55:24Z")

</div>

In the Product Forums section below your question, you have “Katalon-Recorder”. Are you really using Katalon Recorder or are you using the **Web Recorder** of Katalon Studio? They are two different products.

Personal Opinion using Katalon Studio (not Katalon Recorder)  
I still use the OR, so I don’t think you have to give it up completely. However, I have had to go through a **reorganization** from when I first started experimenting/learning with KS and how I use it now. I still have one folder for each web page in the OR. I give my objects a three part name to describe the element’s type, or tag, which section of the web page it belongs and an appropriate name based on the nearest label.

I hope it’s simple and organized enough for the next person to take my position and continue on.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 4:06pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/11 "2022-08-02T16:06:31Z")

</div>

@grylion54 I am using web recorder - [Record Web Utility | Katalon Docs](https://docs.katalon.com/docs/katalon-studio-enterprise/test-design/web-test-design/web-record-and-spy-utilities/record-web-utility#:~:text=Record%20a%20New%20Test%20Case,to%20open%20the%20Web%20Recorder.&text=Select%20a%20browser%20to%20start,%22Open%20Browser%22%20is%20recorded). hmm even we thought of reorganization but not sure if its kind of too late for us with 15K + Object and 2000 test case already present in our repo. what would you suggest

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [August 2, 2022, 4:11pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/12 "2022-08-02T16:11:37Z")

</div>

> [@grylion54](#):
>
> I hope it’s simple and organized enough for the next person to take my position and continue on.

As I stated above, I won’t be continuing in this **Testing** position, so I have hopefully made it convenient for the next person or persons–and I’m only around (down to) 6.5K elements. 🙂

Maybe experiment with “converting” one web page and see if it is worth it, although it will likely be time consuming doing the conversion. But, see if you like the final “effort”.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 2, 2022, 4:56pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/13 "2022-08-02T16:56:37Z")

</div>

Hmm I agree. Thanks @grylion54 for your valuable inputs

---

<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:** [August 3, 2022, 1:58am UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/14 "2022-08-03T01:58:00Z")

</div>

> [@sumiranraut96](#):
>
> we already have 15K+ objects residing in our repo.

I guess that you have tons of duplicating Test Object with different id but with the same locator (XPath expression or CSS Selector). I would guess that you can shrink the existing 15K+ objects to smaller size (e.g, 1K) if you could eliminate all the duplications. The [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) is the primary principle you should follow in managing Test Objects in Katalon Studio.

I am afraid that the [Web Recorder tool of Katalon Studio](https://docs.katalon.com/docs/katalon-studio-enterprise/test-design/web-test-design/web-record-and-spy-utilities/record-web-utility#:~:text=Record%20a%20New%20Test%20Case,to%20open%20the%20Web%20Recorder.&text=Select%20a%20browser%20to%20start,%22Open%20Browser%22%20is%20recorded) does NOT have the DRY principle in design. Rather _it lets you innocently violate the DRY principle_. It makes you, non programmers, be careless enough to creates tons of duplicating Test Objects. Personally I do not use the Web Recorder tool at all because of this unthoughtful design. The Web Recorder is nice to get you started with WebUI test automation. But you should not rely on it long. As soon as you start building test suites of good size, you should stop using the tool.

> [@grylion54](#):
>
> I still use the OR, so I don’t think you have to give it up completely. However, I have had to go through a **reorganization** from when I first started experimenting/learning with KS and how I use it now. I still have one folder for each web page in the OR. I give my objects a three part name to describe the element’s type, or tag, which section of the web page it belongs and an appropriate name based on the nearest label.

I agree with @grylion54’s opinion.

I too give a folder tree of Test Objects that corresponds to the structure of URL of the web pages. This is critically important to eliminate disorder and duplications. Please find an example of [my project](http://forum.katalon.com/t/testing-a-web-app-with-2-browser-windows-opened-simultaneously/61257):

 ![65b9d0b5f6ec6c9b5eda8383813716616e67af95_2_492x1000](https://europe1.discourse-cdn.com/katalon/original/3X/d/f/df1fe20100176139ee5a9e3f651cd5125ff5f24c.png)

Please find subfolders `auth`, `LogInPage` plus a Test Object “`input_Log in`” corresponds to an `<input type="text">` field with label “Log in” in a web page at the URL `http://<hostname>:<port>/auth/login` :

 ![スクリーンショット 2022-08-03 11.49.46](https://europe1.discourse-cdn.com/katalon/original/3X/7/2/72a7ce8c45b51d201e8b8c94beab46bf12b9a3f9.jpeg)

I suppose you would want to learn and apply the [“Parameterize Web Test Objects”](https://docs.katalon.com/docs/katalon-studio-enterprise/test-design/web-test-design/web-test-objects/parameterize-web-test-objects) to reduce the number of Test Objects as well.

Katalon Studio offers no help to find duplicating Test Objects. You need to find them by your deep thinking or developing tools for yourself.

Once you identify which Test Object should be renamed or removed, then Katalon Studio offers a bit of help — it will automatically rewrite the references within the Test Case scprtis to the Test Object.

Hard job, I suppose, but you can do it if you really want to.

* * *

The following post tells my view about Project Object Model in Katalon Studio:

- [(POM) Page Object Model Structure? - #5 by kazurayam - Web Testing - Katalon Community](http://forum.katalon.com/t/pom-page-object-model-structure/62386/5)

@sumiranraut96

POM is a pattern of Object Oriented Progragamming. It requires seasoned programming skill in Java/Groovy. I guess that POM is not the way you can take.

---

<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:** [August 3, 2022, 2:39pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/15 "2022-08-03T14:39:05Z")

</div>

I wrote:

> [@kazurayam](#):
>
> Katalon Studio offers no help to find duplicating Test Objects. You need to find them by your deep thinking or developing tools for yourself.

I would give you a starter for developping tools for you. See the following GitHub project.

> **[GitHub - kazurayam/ObjectRepositoryRetriever](https://github.com/kazurayam/ObjectRepositoryRetriever)**
>
> Contribute to kazurayam/ObjectRepositoryRetriever development by creating an account on GitHub.

My `com.kazurayam.ks.ObjectRepositoryRetriever` class reads the XML config files in the `Object Repository` folder and returns a `List<TestObject>`. My demo test case converts each TestObject instance into JSON text and prints them like this:

```auto
2022-08-03 23:26:39.893 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2022-08-03 23:26:39.897 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/testObjectRepositoryRetriever
2022-08-03 23:26:40.616 DEBUG testcase.testObjectRepositoryRetriever - 1: projectDir = Paths.get(getProjectDir())
2022-08-03 23:26:40.636 DEBUG testcase.testObjectRepositoryRetriever - 2: testObjects = ObjectRepositoryRetriever.readTestObjectFiles(projectDir)
2022-08-03 23:26:42.483 DEBUG testcase.testObjectRepositoryRetriever - 3: assert testObjects.size() > 0
2022-08-03 23:26:42.487 DEBUG testcase.testObjectRepositoryRetriever - 4: println(testObjects.size())
19
2022-08-03 23:26:42.495 DEBUG testcase.testObjectRepositoryRetriever - 5: testObjects.forEach({ java.lang.Object to -> ... })
null
{
  "isParentObjectShadowRoot": false,
  "properties": [
    {
      "name": "id",
      "condition": "EQUALS",
      "value": "comment",
      "isActive": true
    }
  ],
  "xpaths": [],
  "objectId": "Page_AppointmentConfirmation/lbl_Comment",
  "useRelativeImagePath": false,
  "selectorMethod": "BASIC",
  "selectorCollection": {}
}
{
  "isParentObjectShadowRoot": false,
  "properties": [
    {
      "name": "id",
      "condition": "EQUALS",
      "value": "facility",
      "isActive": true
    }
  ],
  "xpaths": [],
  "objectId": "Page_AppointmentConfirmation/lbl_Facility",
  "useRelativeImagePath": false,
  "selectorMethod": "BASIC",
  "selectorCollection": {}
}
...

```

You would want to extend my sample code so that it helps you finding duplicating TestObjects.  
How to do that? …well, I do not know. It is your homework.

---

<div class="post-metadata">

**Author:** ![sumiranraut96](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sumiranraut96/32/20464_2.png) [@sumiranraut96](https://forum.katalon.com/u/sumiranraut96)\
**Post date:** [August 8, 2022, 8:34pm UTC](https://forum.katalon.com/t/webui-test-object-best-practice/67553/16 "2022-08-08T20:34:31Z")

</div>

Thank you so much @kazurayam . I had some urgent deliverables and couldn’t really check your reply . Hope i will be able to solve your homework. 🥲
