In this blog, We will be understanding the concept of Mobile Test Objects and How to manage them in Katalon Studio. So, get ready to learn something new and practical!
Let’s begin, shall we?
Mobile Objects
Let us begin by getting our concepts straight about Mobile Test Objects.
The Mobile object provides access to all the mobile devices connected to the machine. We can specify the current device for the test with the help of their methods which also allow us to get scripting access to it.
Manage Mobile Test Objects in Katalon studio
Why do we use Katalon for Mobile Testing Automation?
We use Katalon for Mobile Testing automation because of the following reasons:
Simple Setup - Katalon Studio comes with all the components and prebuilt keywords to automate your mobile project instantly.
Appium Compliant - Katalon Studio supports all the latest mobile platforms and devices as well as the Appium-based rich ecosystem.
Powerful Object Spying Utility - The UI elements are effectively detected and stored to speed up the scripting process and lessen the maintenance efforts.
Robust Recording Utility - In Katalon Studio, we can easily generate the tests with the mobile recorder and automatically store all the UI elements to be used again.
Optimal Cross-Functional Testing -In Katalon Studio, we can increase Automation efficiency with the help of reusable test objects and scripts across API, web, and mobile platforms.
Cross-Environment Execution - In Katalon, tests can be run locally or remotely with real devices, simulators, or even cloud-based devices.
Cloud-Based Mobile Platform Integration - Integration with other mobile platforms, e.g., Sauce Labs, LambdaTest, etc., is easy.
Let us now look into the main concern of our blog - ‘Managing Mobile Test Objects in Katalon Studio’. Take a look at the following few steps:
After opening the project, firstly, we need to Create a Mobile Object. Right-click on the Object Repository and then New > Mobile Object.
2. As soon as we select the Mobile Object option, a dialog box pops up wherein we need to provide the name and description of the Mobile Object.
3. After that, we need to provide ‘Locator’ and ‘Object Properties’ to our Mobile Object. In the Locator section, we have two fields to fill-
‘Locator Strategy’ gives us a list of options to choose from; we choose 'XPATH’.
‘Locator’- The locator should be unique in detecting that object.
Validate the test object
Next, we need to Validate the Test Object.
We have to add the Test Objects to 'Mobile Object Spy.' Right-click on the object/item to open the menu, where you will find the option of adding the test object to Mobile Object Spy.
Test Objects are added to the Mobile Object Spy to check if the Object can be detected successfully in the application under the test execution.
Add the Object's property
Multiple object properties can be added to the Object's Properties schema. Object properties cannot have the same name in an object.
To add an Object Property, click on Add. As soon as we click on Add, a dialog box pops up:
You need to fill in the required information-Name & Value
Name: It is the name of the object property. You have to enter the name manually.
Value: Give the value corresponding to the name of the object.
After pressing Ok, we see that the property we added is listed in the table. We can add more properties. We can edit, delete or clear the existing ones.
Note: The most significant property of an object is its locator strategy and value.
In Script View
We can define and handle the Test Objects programmatically with the help of Script View:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.testobject.MobileTestObject
import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
// We can either find an object which is already defined in Object Repository using findTestObject
predefinedObject = findTestObject('android.widget.TextView - App')
// We can create a new mobile object programmatically
MobileTestObject mto = new MobileTestObject("TestObjectID")
//defining the locator strategy
mto.setMobileLocatorStrategy(MobileLocatorStrategy.XPATH)
//setting the unique locator
mto.setMobileLocator("//android.widget.TextView[(text() = 'App' or . = 'App')]")
Firstly, select File > New > Test Object from the main menu.
New Test Object dialog box pops up wherein we need to provide a name for the new test object and then click the Ok button.
After clicking Ok, we observe that a new Test Object is created in the Object Repository.
‘Attributes’ is selected by default to locate mobile test objects.
Several properties make up a Test Object based on which Katalon Studio detects an object during test execution.
Add an object's property
Multiple object properties can be added to the Object's Properties table. It’s important to note that object properties cannot share the same name in an object.
We can add properties in the Object’s Properties panel by clicking on ‘Add’
As soon as the ‘Add property’ dialog box pops up, We need to fill in the required information:
Name: Name the object property. You can choose one of the options from the dropdown list (class, css, id, name, title, xpath) or manually enter a name.
Match condition: The condition helps in detecting the target object during execution time.
Value: The value that completes a match condition goes here.
After clicking on ‘Ok’, the new property is added to the properties list. You can also edit the properties' values here.
Validate Test Object on AUT
Test Objects are added to the Mobile Object Spy to check if the object can be detected successfully in the application under the test execution.
Right-click on the object/item to open the menu, where you will find the option of adding the test object to Mobile Object Spy
We can define and handle the Test Objects programmatically with the help of Script View:
//Refer to existing objects using the findTestObject() method:
// This is to find an object which is already defined in Object Repository
predefinedObject = findTestObject(‘android.widget.TextView - App’)
//Or we can create a new object programmatically using the'TestObject' class:
newObject = new TestObject(“ObjectID”)
// Using addProperty() ,add property to the Test Object - property name, condition type, property value,a boolean value
newObject.addProperty(“class”, ConditionType.EQUALS, “android.widget.TextView”, true)
Frequently Asked Questions
What are some common challenges in mobile application testing?
Test cases execution with different operating systems
Testing the applications on various mobile networks
Different ways are required to test different application types like hybrid, web app, or native
What are some common bugs found while mobile testing?
Critical: Crashing of your phone system
Block: Unable to use the phone until it’s rebooted
Major: Not being able to perform a function of a specific feature
Minor: Usually, the GUI bugs fall under minor bugs.
When to choose manual testing?
We choose Manual testing when the application has some new functionality or requires testing to be done once or twice.
Conclusion
We hope this blog helped you prick your brain on How to manage Mobile Test Objects in Katalon. The blog introduces you to the concept of Mobile Test Objects and how to manage them in Katalon Studio.