Can I parameterize a part of test object resource-id

Are there any changes a few months later? Can I directly set the Global variable into TestObject property’s value (something mentioned above)?

I am not sure.

@devalex88, @ThanhTo ?

1 Like

@kazurayam I faced exactly the same use-case as a topic-starter. I have 3 applications to run Katalon-tests with. All these applications is basically copy-pasted from the main one, so my test-scripts can be run for each of 3 apps. But package name for each of them differs. All my test object were created by “Spy Mobile” option and (I don’t know why(!!!)) “resource-id” parameter always begins with “packageName” of the app. So I have the same objects to deal with (tap for example) but these objects do have different values in “resource-id” parameter, therefore I cannot interact with these object as it is.

  • first app “resource-id” = myAppName1:/login
  • second app “resource-id” = myAppName2:/login
  • third app “resource-id” = myAppName3:/login

Currently I cannot run my tests for all my apps. So I decided to edit all “resource-id” parameter’s values during test execution as described above. I set variables to all my “resource-id” related objects quickly with search-replace Katalon option, but now I need to adjust all my “resource-id” related test-steps
I need to change
Mobile.tap(findTestObject(‘Welcome_Login button’), 0)
Mobile.tap(findTestObject(‘Welcome_Login button’, [(‘packageName’): GlobalVariable.G_packageName]), 0)
And I am afraid I need to change it manually (:sob::sob::sob::sob::sob:)
I have about 300 places to modify and it requires a lot of time, this is a big “monkey job”.
Is there a quick way yo do so? Thanks a lot.


Katalon Studio v6.3.0 introduced an improvement

Does it help?

Partially yes, thanks!
Can I use the same approach in my Keywords methods?
I mean can I use
Mobile.tap(findTestObject(‘MyTestObject’, [(‘packageName’): GlobalVariable.G_packageName]), 0)
in my CustomKeywords.‘’() method?

I think it would work. Just try it.

Can I use the same approach in my Keywords methods?

I will rather write the keyword with a String parameter and pass the Global as parameter to the method when calling it from the testcase.

This way your keyword code will be reusable, I tend to avoid hardcodings as much as possible.

I fact, to add more flexibility i will do such design:

  • the keyword takes the needed value as a string parameter
  • i declare a variable in the testcase mapped to the needed global
  • i call the method from the testcase using the testcase variable

With such design you have the possibility to override the value passed to the keyword by 3 means: from the global value, modifying the variable in the testcase or simply calling the keyword with a fixed value

and if the testcase variable is not local (declared in the code) but you create it using the variables tab, it will be visible to other testcases too. so you can override the passed value by calling the testcase from another testcase using parameters mapping.


I have the same problem here… to do a work around I did a copy of my project and I tried using powershell to do a find and replace in all *.rs files the resourceid with the other one but now all the object that had a change in them are not available in Katalon??? how come, is there a way to get back the objects after a change done in the files when not using Katalon to do it?

Hi all,

I found why katalon was not recognizing my objects… powershell was changing the encoding from UTF-8 to UTF16 LE BOM… So a quick way to duplicate your project with another package name in Powershell, create a copy of your project and run this script:

$exclude = @(“log”, “bak”)
$files = Get-ChildItem -Path “D:\projectCopy
Path*.rs” -Recurse -exclude $exclude

foreach ($file in $files){

$find = “packageName1”
$replace = “packageName2”
$content = Get-Content $($file.FullName) -Raw
#write replaced content back to the file

$content -replace $find,$replace | Out-File -Encoding utf8 $($file.FullName)

I found a way to change the resource-id everywhere to put the globalvariable for packagename but then you need to add the parameter in your test cases…

$exclude = @(“log”, “bak”)

$files = Get-ChildItem -Path “D:\temp*.rs” -Recurse -exclude $exclude

foreach ($file in $files)

$find1 = "@resource-id = packageName:id/"
$replace1 = "@resource-id =  '`${GlobalVariable.packageName}:id/"
$find2 = "<value>packageName:id/"
$replace2 = "<value>`${GlobalVariable.packageName}:id/"

$content = Get-Content $($file.FullName) -Raw

    $content | ForEach-Object {

    $_ -replace $find1,$replace1 `
     -replace $find2,$replace2 

     }| Out-File -Encoding utf8 $($file.FullName)



1 Like

iam new on automation with this tools
how to use this script ?
on testcase or what else ?
can you help me.


@rahman.darmawan start from here:

@Ibus thanks for responds.
fundamental about katalon iam done to read, but i want to ask about script @jtheoret how to use
couse i dont want to replace manually all object :sweat_smile:

Anyone to help about this ?

It’s a script in powershell that I used to do the string manipulation in the object repository of my project. all the object that you have in your project are .rs files you can open the file with notepad++ to see how it is built.

Powershell ISE is a Microsoft task automation program where you can run scripts.

I suggest that you put your project in a temps folder to test the string manipulation and then when you are satistied you run it on you project :slight_smile: also this won’t change in your script the parameter that you need to add in the find object. This part I did manually.

Isn’t the simplest solution for this is for Katalon to implement the UIautomator calls to resourceIdMatches() , so we can use regex instead of always having to put the package name in through a global variable. It seems clunky to do so when a simpler solution exists.:

It is rather frustrating because if I was just using Appium or raw UIAutomator this feature is right out of the box…
@devalex88, @ThanhTo

I found also that you can remove the packagename in the resource-id and choose contain instead of equal for the value of the attribute. this way you don’t need to add the parameter in the object when you call it…

I’m using contains for resource-id and contains doesn’t work, relevant information:
Mobile platform: Android 7.0
Katalon version: 7.4.0
Appium version: 1.16.0