each and every time I have to follow the above procedure for using a test object in my test case
I do not see what you mean.
You can switch Execution Profile, a set of GlobalVariables, to apply to a Test Suite execution.
Create a Test suite “TS0” which binds your 100 test cases. And create 2 Profiles “prof1”, and “prof2” each of which contains GlobalVarialbe.packageName with different values: ‘my.package.a’ and 'my.package.b". Then you can easily choose executing TS0 with “prof1” or TS0 with “prof2”. I suppose this approach is easy enough. Isn’t it for you, Sravya?
Can I know where you have created the above test object so that all the test objects take the global variable value while running a test suite?
I suppose you used Web Recorder or Spy Web to generate your 100 test objects, but you have never edited test objects manually, have you?
Web Recorder will never automatically generate this:
You need to manually edit the value of property of a Test Object. See the following screenshot.
I am saying you should edit 100 test objects manually. You would need to edit your test cases accordingly.
Yes, of course, I have edited everything manually and assigned a global variable in the profiles. The only way I know to bind the value of the global variable to the test object is to assign it in the test case I am running. For example, If I am having a login test case, Where I need to enter email id, to the email id test object inside the test case I need to assign a variable that is taking the value from the global variable and binds it to the test object. I need to assign a variable for every test object I am using in the test case.
I am not sure if it is the same solution that you are providing too. I was thinking if there is any way where the test object that is edited manually takes the value from the global variable directly.
@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)
to Mobile.tap(findTestObject(‘Welcome_Login button’, [(‘packageName’): GlobalVariable.G_packageName]), 0)
And I am afraid I need to change it manually ()
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.
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.‘com.android.MobileKW.swipeTo’() method?
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?
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: