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.
From version 7.8.0 onwards, Kobiton accounts using SAML SSO login method can integrate with Katalon Studio. See Kobiton documentation on Configuring Single Sign-On/SSO and SAML with Kobiton.
Enable Kobiton Integration
Kobiton is a mobile device platform that offers real mobile devices for both testers and developers. Using Katalon Studio, you can execute automated tests on Kobiton devices. To enable Kobiton integration, follow these steps:
-
Install the Kobiton Integration plugin from Katalon Store. After installing the plugin, open Katalon Studio > Your Account > Reload Plugins. You can refer to the section Reload Plugins for detailed instructions.
- Open Kobiton integration settings from the main menu:
- Windows: Windows > Katalon Studio Preferences > Katalon > Kobiton.
- macOS: Katalon Studio > Preferences > Katalon > Kobiton.
- Select Enable Kobiton Integration and authenticate your access to the Kobiton Server.
-
From version 7.8.0 onwards: enter you Kobiton username and Kobiton API Key, then click Test Connection.
- Kobiton Server: The Kobiton server to be integrated with Katalon Studio.Note:
From version 8.1.0 onwards, you can customize the remote server protocol and path name. Katalon Studio uses HTTP protocol by default. If your environment prevents sending basic authentication credentials through HTTP, you can input a remote URL with HTTPS instead.
- API Key: The token to be used by Katalon Studio when exchanging API messages with Kobiton server. You can generate more keys in Kobiton API Settings.
- Kobiton Server: The Kobiton server to be integrated with Katalon Studio.
-
Prior to version 7.8.0, enter your Kobiton account in the Authentication form and click Connect. Katalon Studio retrieves the information for Kobiton integration automatically.
-
- When you are done with the configuration, click Apply and Close.
Desired Capabilities for Kobiton Devices
Kobiton integration is enabled, and you have adjusted your existing test scripts accordingly. Refer to Enable Kobiton Integration for more details.
You can add additional desired capabilities for Kobiton devices, such as using the appWaitActivity
capability to troubleshoot an issue related to starting an application. See Troubleshooting automated mobile testing.
- Copy the desired capabilities: In the Kobiton portal, select the device you want to use. Click Automation Settings and copy the desired capabilities. For example:
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 J3(2016)");
capabilities.setCapability("platformVersion", "6.0.1");
capabilities.setCapability("platformName", "Android");Open Katalon Studio, then paste these desired capabilities to your test script.
-
In Kobiton portal, open your app. 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 example,kobiton-store:v488518
).Insert
app
capability and pass in Kobiton application id for your device, for example:capabilities.setCapability("app", "kobiton-store:v488518");
3. 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 change
MobileDriverType.ANDROID_DRIVER
toMobileDriverType.IOS_DRIVER
.Now you have finished adjusting the
Mobile.startApplication
keyword. Here is the complete 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.
To dynamically change Kobiton devices in console mode, see Integration Options.
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.