Designing the test suite / project - minimize the number of test objects

Hello, I’d appreciate some insight on how to properly design test project.

The issue is on how to avoid a clutter of test objects. I’ve read about parameritized test objects, but can’t seem to grasp them enough to put them in action.

Example on web application we have ~20 tabs which all have the same div class atribute and unique ID. The idea is to have one test object which would consist of class=tab and ID=$variable instead of 20 test objects which would rely on unique ID.

So test object would be

//div[@id=$tab_id and @class='tab']

Afterwards we’d call the test object from test case and pass the value for variable $tab_id.

a) Is this a good idea or are there better practices on how to handle this?
b) Is this achievable via Katalon GUI w/ the need to code some additional scripts?

a) Yes, I think it is a good idea and following the best practice.

b) Please try the following:

XPath should rather be:

//div[@id='${tab_id}' and contains(@class,'tab')]
  1. the value of @id needs to be quoted to be a string in xpath
  2. the value of @class tends to have multiple consecutive names: for example “navbar topnav tab”. therefore you should use contains() function rather than strict equality test by =

Your test case would look like:

WebUI.verifyElementPresent(findTestObject('Object Repository/yourTestObjectName',    ['tab_id':'TAB111']), 10)...WebUI.verifyElementPresent(findTestObject('Object Repository/yourTestObjectName',    ['tab_id':'TAB222']), 10)...WebUI.verifyElementPresent(findTestObject('Object Repository/yourTestObjectName',    ['tab_id':'TAB333']), 10)

The place-holder “tab_id” will be interpolated with ‘TAB111’, ‘TAB222’ and ‘TAB333’


I think it should be also mentioned that in order for this parameterized xpath to work you have to add the xpath to selection method “attributes” of the object rather than directly to the “xpath” selection method. Just in case someone reads this :slight_smile: