Parametrization of test object

Hi there,

My xpath to expand the first row is set as //div[5]/div/table/tbody/tr[contains(td[4],‘TS4kat’})]/td[1]/input
(Note: it is 4th column not 3 as per html.)

now I want to expand all the rows below it. For that I use parametrization. Thus, I update the xpath as //div[5]/div/table/tbody/tr[contains(td[4],${expand})]/td[1]/input

I define variable as expand_1 , type= list , values= [“Ts2kat”,“TS3kat”,“TS1kat”]

I apply for loop as below,
for (def expand : (1…4)) {‘require risk master/Test strategy/Page_Validator/input_expnad TS’, [(‘expand’) : expand_1]))

expand_1 +=1

Now my question is , am I missing something? Any wrong step to define parameterization? whole execution only expand first row repeatedly.

I tried to reproduce you code as follows (Code1):

// Code1
List<String> expand_1 = ["Ts2kat", "TS3kat", "TS1cat"]
for (def expand:(1...4)) {
    println "expand:${expand_1}"
expand_1 += 1

The Code1 does not compile because 1...4 is not a valid expression in Groovy.

I modified the Code1 to the Code2 as follows. I wrote 1..4 instead of 1...4:

// Code2
List<String> expand_1 = ["Ts2kat", "TS3kat", "TS1cat"]
for (def expand:(1..4)) {
    println "expand:${expand_1}"
expand_1 += 1

The Code2 compiles and runs. It printed the following output in the Console.

2021-11-09 08:34:52.656 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/kparehk
expand:[Ts2kat, TS3kat, TS1cat]
expand:[Ts2kat, TS3kat, TS1cat]
expand:[Ts2kat, TS3kat, TS1cat]
expand:[Ts2kat, TS3kat, TS1cat]

I suppose this is not what you want.

I modified the Code2 to the Code3 as follows:

// Code3
List<String> expand_1 = ["Ts2kat", "TS3kat", "TS1cat"]
for (int i = 0; i < expand_1.size(); i++) {
    println "expand:${expand_1[i]}"

When I run the Code3, it printed the following in the Console.

2021-11-09 08:36:17.352 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/kparehk

I suppose this is what you wanted.

The Code3 is not very Groovyish. The following Code4 does just the same as the Code3, and is in a better style.

// Code4
["Ts2kat", "TS3kat", "TS1cat"].each({ entry ->
    println "expand:${entry}"

@kazurayam I applied your suggestion code3 as below .
List expand_2 = [“TS2kat”, “TS3kat”, “TS1kat”]

for (int i = 0; i < expand_2.size(); i++) {
println “expand:${expand_2[i]}”‘require risk master/Test strategy/input_expnad TS1-parameterise’))

It prints what is in the list but my actual action is to expand each of them. It only expand TS4 repeatedly which is on position tr-1.

Let me know where is the mistake?

You have this now:


You should amend it to:


A pair of quotations is required around ${expand}.

@kazurayam Hi Sorry for late reply. I applied quotes. //div[5]/div/table/tbody/tr[contains(td[4],"${expand}")]/td[1]/input[1]. Still it always open TS4.
Actually it doesn’t applied this xpath. Pls see below error logs ,

2021-11-12 09:12:42.191 DEBUG testcase.TC-OQ-123- requirement risk - 7: delay(2)
2021-11-12 09:12:44.219 DEBUG testcase.TC-OQ-123- requirement risk - 8: expand_2 = [“TS2kat”, “TS3kat”, “TS1kat”]
2021-11-12 09:12:44.221 DEBUG testcase.TC-OQ-123- requirement risk - 9: for ([i = 0, i < expand_2.size(), (i++)])
2021-11-12 09:12:44.222 DEBUG testcase.TC-OQ-123- requirement risk - 1: println(expand:$expand_2[i])
2021-11-12 09:12:44.263 DEBUG testcase.TC-OQ-123- requirement risk - 2: click(findTestObject(“require risk master/Test strategy/input_expnad TS1-parameterise”))
2021-11-12 09:13:15.537 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //div[5]/div/table/tbody/tr[contains(td[4],"${expand}")]/td[1]/input[1]’. Please recheck the objects properties to make sure the desired element is located.
2021-11-12 09:13:15.538 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/require risk master/Test strategy/input_expnad TS1-parameterise’. Try using Self-healing.
2021-11-12 09:13:15.832 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] The current locator of test object ‘Object Repository/require risk master/Test strategy/input_expnad TS1-parameterise’ was broken. Propose an alternative one: ‘//input[@id=‘ctl00_cphMain_RadGridTestStrategy_ctl00_ctl04_GECBtnExpandColumn’]’.
2021-11-12 09:13:15.933 DEBUG testcase.TC-OQ-123- requirement risk - 3: delay(3)

change it to:
    ‘require risk master/Test strategy/input_expnad TS1-parameterise’),
    ["expand": expand_2[i]]