WebUI Test Object - Best Practice

I wrote:

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

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:

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.

1 Like