Kobiton Integration with Katalon Studio
Kobiton is a mobile device platform that offers real mobile devices for testers and developers. With Kobiton and Katalon Studio integration, you can easily execute automated tests on real mobile devices.
This article will guide you on how to integrate Kobiton with Katalon Studio and how to run Katalon automation scripts on Kobiton devices using Kobiton's desired capabilities.
Enable Kobiton Integration
- Install the Kobiton Integration plugin from Katalon Store. After installing the plugin, open Katalon Studio, then select . You can refer to the section Reload Plugins for detailed instructions.
- Open Kobiton integration settings from the main menu:
- Select Enable Kobiton Integration and authenticate your access to the Kobiton Server.
- When you are done with the configuration, select Apply and Close.
The Kobiton - Katalon Integration is enabled successfully. Desired capabilities for Kobiton devices
In order to run Katalon automation scripts on Kobiton devices, you need to specify Kobiton devices desired capabilities in the script. - On the Kobiton portal, select a mobile device on which you want to run automation test. Select Automation Settings and copy the desired capabilities. You can also refer to Kobiton's documentation for this step: Getting Started with Appium Testing with Kobiton. Here is a sample of desired capabilities for mobile device retrieved from Kobiton portal:
String kobitonServerUrl = "https://katalon-integration:xxxxxxxxxxxxxxxxxxx@api.kobiton.com/wd/hub";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("sessionName", "Automation test session");
capabilities.setCapability("sessionDescription", "");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("captureScreenshots", true);
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("deviceGroup", "KOBITON");
capabilities.setCapability("deviceName", "Galaxy S10");
capabilities.setCapability("platformVersion", "12");
capabilities.setCapability("platformName", "Android");
- In Katalon Studio, open your test case and switch to the Scripts view for the automation script. Then paste the desired capabilities in your script.
- On the Kobiton portal, open your app. In the upper right corner of the app tile, select Automation Snippet. Then, copy the value of the app ID to your clipboard (for example,
kobiton-store:v488518
). - Back to Katalon Studio, insert the app ID from Kobiton app repository as a desired capability to your Katalon script, for example:
capabilities.setCapability("app", "kobiton-store:v488518");
- Replace
Mobile.startApplication
keyword with these lines. These codes establish a connection to selected Kobiton device and create a driver to be used for other built-in keywords. Therefore, you do not have to rewrite the whole test script again.
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.appium.driver.AppiumDriverManager
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
import com.kms.katalon.core.mobile.driver.MobileDriverType
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.util.internal.PathUtil as PathUtil
import internal.GlobalVariable as GlobalVariable
import io.appium.java_client.android.AndroidDriver
//Mobile.startApplication('kobiton-store:10717', false)
String kobitonServerUrl = "https://katalon-integration:xxxxxxxxxxxxxxx@api.kobiton.com/wd/hub";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("sessionName", "Automation test session");
capabilities.setCapability("sessionDescription", "");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("captureScreenshots", true);
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("deviceGroup", "KOBITON");
capabilities.setCapability("deviceName", "Galaxy J3(2016)");
capabilities.setCapability("platformVersion", "6.0.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", "kobiton-store:v488518")
AppiumDriverManager.createMobileDriver(MobileDriverType.ANDROID_DRIVER, capabilities, new URL(kobitonServerUrl))
If you use an iOS device, you need to changeMobileDriverType.ANDROID_DRIVER
to MobileDriverType.IOS_DRIVER
.
Now you have finished adjusting the
Mobile.startApplication
keyword. Here is the complete sample code:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.appium.driver.AppiumDriverManager
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
import com.kms.katalon.core.mobile.driver.MobileDriverType
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.util.internal.PathUtil as PathUtil
import internal.GlobalVariable as GlobalVariable
import io.appium.java_client.android.AndroidDriver
'Instead of using Start Application keyword, we use the below code to create a similar driver so that other Mobile built-in keywords can re-use this driver.'
String kobitonServerUrl = "https://katalon-integration:xxxxxxxxx@api.kobiton.com/wd/hub";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("sessionName", "Automation test session");
capabilities.setCapability("sessionDescription", "");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("captureScreenshots", true);
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("deviceGroup", "KOBITON");
capabilities.setCapability("deviceName", "Galaxy J3(2016)");
capabilities.setCapability("platformVersion", "6.0.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", "kobiton-store:v488518")
AppiumDriverManager.createMobileDriver(MobileDriverType.ANDROID_DRIVER, capabilities, new URL(kobitonServerUrl))
Mobile.tap(findTestObject('Application/android.widget.TextView - App'), 10)
Mobile.tap(findTestObject('Application/App/android.widget.TextView-Activity'), 10)
Mobile.tap(findTestObject('Application/App/Activity/android.widget.TextView-Custom Dialog'), 10)
'Get displayed message on the dialog'
def message = Mobile.getText(findTestObject('Application/App/Activity/Custom Dialog/android.widget.TextViewCustomDialog'),
10)
Mobile.comment('Then the correct dialog message should be displayed')
Mobile.verifyEqual(message, 'Example of how you can use a custom Theme.Dialog theme to make an activity that looks like a customized dialog, here with an ugly frame.')
Mobile.closeApplication()
Mobile Testing With Kobiton Devices
Install and enable the Kobiton Integration plugin. If you haven't configured the integration yet, refer to this section: Enable Kobiton Integration for instructions.
To do this, follow the instructions below to execute your Katalon Studio automation test with Kobiton mobile devices.
1. Navigate to Kobiton Portal and log in with your Kobiton username and password.
2. In Kobiton, upload your app to the Kobiton App Repository. See Kobiton documentation on Managing Applications.
3. In the upper right corner of the app tile, click on Automation Snippet. Then, copy the value of the app
capabilitiy to your clipboard for later use (for example, kobiton-store:v488518
as shown below).
4. Click on the Devices menu. Select your device, then click on the star in the top right corner to Mark as favorite.
From version 8.1.0 onwards, you can change the Custom Device Name of Kobiton device to select the correct device on Katalon Studio. If your Kobiton devices don't have any custom name, Katalon Studio uses the devices' original name when running tests. See Kobiton documentation on Device Custom Name.
Once you have set your Device Custom Names in Kobiton Portal, you can check the Kobiton devices list in Katalon Studio. Go to Katalon Studio, then open Mobile Recorder/Spy > Select Kobiton Device.
5. In Katalon Studio, open your mobile test case and switch to the Scripts view. Locate this line of code:
Mobile.startApplication('appPath', false)
Next, replace the appPath
with the Kobiton app
capability saved in Step 3, as shown below:
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
Mobile.comment('Story: Verify correct alarm message')
Mobile.comment('Given that user has started an application')'Get full directory\'s path of android application'
//def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())
Mobile.startApplication('kobiton-store:v488518', false)
Mobile.comment('And he navigates the application to Activity form')
Mobile.tap(findTestObject('Application/android.widget.TextView - App'), 10)
Mobile.tap(findTestObject('Application/App/android.widget.TextView-Activity'), 10)
Mobile.comment('When he taps on the Custom Dialog button')
Mobile.tap(findTestObject('Application/App/Activity/android.widget.TextView-Custom Dialog'), 10)
'Get displayed message on the dialog'
def message = Mobile.getText(findTestObject('Application/App/Activity/Custom Dialog/android.widget.TextViewCustomDialog'),10)
Mobile.comment('Then the correct dialog message should be displayed')
Mobile.verifyEqual(message, 'Example of how you can use a custom Theme.Dialog theme to make an activity that looks like a customized dialog, here with an ugly frame.')
Mobile.closeApplication()
6. From the main toolbar, click on the drop-down menu of Run, and select the option to run with Kobiton Device.
7. The Kobiton Favourite Devices dialog appears. In the dropdown list of Device Name, select a Kobiton device to run your test and click OK. You can also modify this list by updating your Favorite Devices from Kobiton Portal.
8. Once Katalon Studio finishes configuring, the automated test execution session will be uploaded to Kobiton.
You can view the session in the Sessions section in Kobiton. To learn more about Kobiton session, see Kobiton document: Session List.