My app has same work-flow on both iOS & Android, so I don’t want to spend effort to split the test (one for Android, another one for iOS), it’s a kind of duplication and hard for us to do maintain later.
I create the custom keyword to return to correct TestObject base on test device (iOS Objects and Android Objects have same structure).
But if we’re using the Custom Keyword then TestObject doesn’t update itself in the test-script. I think this one need some knowledge inside Katalon development team.
I’d be great if you guys can shed a light OR help to add one more keyword to fit above purpose.
// I tag some Katalon Developers which I see on the forum here because this one needs the knowledge inside of Katalon development team. I’m sorry if it causes any inconvenience. @ThanhTo@Zarashima@Brian_Ducson
Does that line print the correct path? Maybe I’m missing something, but I don’t see anything wrong with what you are doing here.
However, I would make the keyword a static and import the class statically everywhere you wish to use it:
package com.mypackage
public class MyClass {
// @Keyword <== You don't need this
static TestObject findObject(String objectPath) {
String objectRepo = Mobile.getDeviceOS().equals('iOS') ? 'iOS Objects': 'Android Objects'
String actualObjectPath = objectRepo + '/' + objectPath
println actualObjectPath
return findTestObject(actualObjectPath)
}
}
In your Test Case:
import static com.mypackage.MyClass.* // import all static methods from MyClass
// get the button for the correct platform, iOS/Android...
TestObject button = findObject("my_button")
WebUI.click(button)
The changing of folder/path can be managed by having a static variable which you keep updated to the correct path. Then you only have to change it in one place.
I’m not sure why you would change the name but you could use the same approach for the name, too.
I just think before I apply this for all projects. I did same approach as you, but it only can change parent/root folder.
Update Test Object doesn’t happen frequently, but assume that we have a lot Test Objects and a lot of Test Cases, one TestObject is used in some-test-cases then it’d be very convenient if we update something on TestObject and Katalon helps to update/refactor that in related TestCases (as what Katalon has now for Built-in Keyword findTestObject).
But that is the reason why I am suggesting you put the things that can change (variables) in ONE place (in a keyword class) and make sure your Test Cases ALWAYS refer to the variables. Then you only have ONE THING to change in ONE PLACE.
first: update TestObject (change name or move to another folder, etc…)
second: update variable in the Class
→ do I understand it correct ?
If yes, then because we have many screens/pages, then we will have many Classes like this, unfortunately we have many projects under main project, a lot of thing need to add there and maintain later.
The goal of Katalon is to help non-tech QA can write automation-test, that’s why I’m asking if there is anyway to have a same feature (which already exists for built-in keyword) for a custom keyword.
it’s fine, I was afraid that my word was not clear enough, so just create video to make it more clear.