Test object parametrization is failing

Hi I am using Katalon version 7.2.1 and experiencing a weird issue regarding test object parametrization.

First tried with driverFactory and then tried with parametrizing the test object itself. But experiencing the same issue

  1. My test object- name is selectApp
    //span[contains(text()=’${appName}’)]

  2. I have attached the variable property with Test object
    ‘Select App to login’
    WebUI.click(findTestObject(‘LoginXpress/SelectApp’, [(‘appName’) : appName]))

  3. Below is my variable defined in variable tab
    Katalon studio Test object Parametrization issue

  4. When I am running the script, error is shown that unable to locate the element because somehow the 2nd quote is going to the next line

  5. Same error if I use the driver factory

But weird thing if I use the quotes in variable value itself then it works.
If I use variable like
image
and driverFactory like below then it works

am I doing something wrong when adding quotes in the test object itself?

You have this as a XPath expression now:

//span[contains(text()=’${appName}’)]

It is wrong. It should be:

//span[contains(text(), ’${appName}’)]

Yes you are right, I made a mistake while writing here. But if you see DriverFactory xpath that is correct with ‘,’. But I am having the issue that 2nd quote is going to next line and because of this one space is getting added just before the 2nd quote

@kazurayam I tried again by correcting it in the test object repository but same issue still happens

As I mentioned above, If I use the quotes in the string variable value itself like (‘Schedule Xpress’) instead of passing in the test object then it works perfectly.

hi,

i guess no needed to add quotes here
image
if
used like
("//span[contains(text(),’+appName+’)]")).click()

No it doesn’t work if I use as above. In this case the variable name ‘appName’ will become a string. The correct syntax is
("//span[contains(text(),"+appName+")]")).click()

and it only works if I pass the quotes in the variable value.

Could you take a screenshot of the selector definition of your Test Object LoginXpress/SelectApp ?

I tried to mimic your case and found an interesting stuff.

I created a Test Case, and defined a Variable appName. I intentionally appended a NewLine character at the end of the default value. The NL character is actually appended and saved.

I saved the appName. I found, value of appName rendered in the view is different from its actual value: new line character in the default value is not visible, but actually there. Very confusing!

@Bhawna_Rani

Please check the default value of the Test Case variable appName. I suppose you have a new line character at the tail.

2 Likes

@ThanhTo

I am sure this is an issue to be addressed by Katalon Team.

1 Like

Thanks @kazurayam

I opened an issue

2 Likes

Thank you so much @kazurayam. Yes, I had the new line character which got inserted by unknowingly just clicking enter after entering the value. After removing the new line character, my problem is solved.

Thanks again for taking the time to look into the issue.

Hi hi.
i’ve been hit by this too, many times, this is where the script view became very usefull for variables.
Indeed, pressing ‘enter’ when adding value for a certain variable acts funny :slight_smile:

The issue may have to be updated a bit. It is not to display the newline (that can be checked in scriptview) but the form for entering the value has to be fixed, the workaround is to click somewhere around after filling the data. I was expecting when hitting enter, the value to be saved.
And i bet plenty other similar reports on ‘parametrization now working’ are caused by this behavior
If, for certain reasons, newline is desired, usage of alt+enter may be needed. Such functionality has to be checked too (sorry, i am too lazy to check it)

Yes, exactly the same thing happened to me. I hit enter after entering the value assuming that my value will be saved but instead, it added the new line character :slightly_smiling_face: