Kobiton Tutorial – Mobile Testing Platform with Real Devices
In this tutorial, we are going to present one of the popular tools (i.e., Kobiton). We will let you know what is Kobiton and what makes us bring this Kobiton Tutorial before you.
No more Emulators. Yes, you can run your tests on real devices. You can perform all the gestures you need to test on a real device. Tap, swipe, and scroll on a cloud device, simply and naturally.
In this Kobiton Tool Review, we are going to see the following
- 1. Kobiton Tool Introduction
- 2. Kobiton Features
- 3. Kobiton Tool Registration
- 4. Setting Up Desired Capabilities
- 4.1. Desired Capabilities For Android device
- 4.2. Desired Capabilities For iOS device
- 4.3. Capture Screenshots
- 5. Creating And Running A Mobile Browser Test
- 6. Sample Program to Run Selenium Script on Android Device
- 7. Sample Program to Run Selenium Script on iOS Device
Kobiton Tool Introduction
Kobiton is a cloud platform for executing automated and manual mobile and web tests. Kobiton supports running automated tests with Selenium WebDriver (for web applications) and Appium (for native and mobile web applications).
You can test your websites with your favorite language – no need to learn specific scripting languages or learn a new programming language. In addition, you also don’t need to install testing SDKs and even the Appium binding can be a pain point for test and dev team. When you run Appium in the cloud, there is no need to install Appium and set up your devices. You’ll have access to test on hundreds of browsers instantly.
Today, I’ll walk you through a basic example of how to use Appium / Selenium for mobile cross-browser testing using real Android and iOS devices and real web browsers on these platforms on Kobiton Cloud.
Kobiton Features
- Manual and Automated Testing on Real Devices
- It supports Parallel Testing
- It allows to record video and capture screenshots & user interactions
- Integration with popular tools like Jenkins, JIRA, GitHub, Travis CI, TeamCity
- It Supports Appium, Selenium & Katalon Studio
Kobiton Tool Registration
We need to register to start working with Kobiton Tool. So let’s move ahead to create a free trial account and sign in. It takes just a few moments.
Step 1: Go to official website of Kobiton to create a free account on Kobiton account
Step 2: Enter your login credentials (such as ‘Email’ and ‘Password’) and click on ‘Log in’
You will be redirected to your devices page of Kobiton.
Setting Up Desired Capabilities
Hover over the device you want to test and select Show automation settings for Java language as below:
Desired Capabilities For Android device
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session on Android web"); capabilities.setCapability("sessionDescription", "This is example Android web testing"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "chrome"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "Galaxy Note5"); capabilities.setCapability("platformVersion", "6.0.1"); capabilities.setCapability("platformName", "Android");
Desired Capabilities For iOS device
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session on iOS web"); capabilities.setCapability("sessionDescription", "This is example iOS web testing"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "safari"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "iPhone X"); capabilities.setCapability("platformVersion", "11.4.1"); capabilities.setCapability("platformName", "iOS");
Capture Screenshots
It allows skipping screenshots for each HTTP command or not. Depending on these screenshots, we can know the error or UI issue during running automation test. Please see the example:
capabilities.setCapability("captureScreenshots", true); // Or false
Portrait/Landscape
It’s possible to rotate the device before your test and you will have a different view of your website. Please see the example:
Rotate before test:
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceOrientation", "portrait"); // Or "landscape"
Creating And Running A Mobile Browser Test
After all these steps have been done, let’s look at how to use WebDriver to get the test running. First, you need to initiate the WebDriver. Note that if you are using client-side execution this really may take some time as the device will be prepared for your session.
String kobitonServerUrl = "https://rajkumarsm:a9fe5690-1265-479a-8389-6f6b67589352@api.kobiton.com/wd/hub"; RemoteWebDriver driver = new RemoteWebDriver(new URL(kobitonServerUrl),capabilities);
Sample Program to Run Selenium Script on Android Device
This code example illustrates setting up a simple Java test to find the title of Appium page.
For Android device
import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import java.net.URL; public class RemoteWebDriverAndroidTest { public static void main(String[] args) throws Exception { String kobitonServerUrl = "https://rajkumarsm:a9fe5690-1265-479a-8389-6f6b67589352@api.kobiton.com/wd/hub"; DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session on Android web"); capabilities.setCapability("sessionDescription", "This is example Android web testing"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "chrome"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "Galaxy Note5"); capabilities.setCapability("platformVersion", "6.0.1"); capabilities.setCapability("platformName", "Android"); RemoteWebDriver driver = new RemoteWebDriver(new URL(kobitonServerUrl), capabilities); /** * Prints Kobiton Session Id */ String kobitonSessionId = driver.getCapabilities().getCapability("kobitonSessionId").toString(); System.out.println("Your test session is: https://portal.kobiton.com/sessions/" + kobitonSessionId); driver.get("http://appium.io/"); /** * Goes to Appium page and prints URL & title */ System.out.println("Current URL is: " + driver.getCurrentUrl()); System.out.println("Title of page is: " + driver.getTitle()); driver.quit(); } }
Sample Program to Run Selenium Script on iOS Device
This code example illustrates setting up a simple Java test to find the title of Appium page.
For iOS device
import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import java.net.URL; public class RemoteWebDriverIOSTest { public static void main(String[] args) throws Exception { String kobitonServerUrl = "https://rajkumarsm:a9fe5690-1265-479a-8389-6f6b67589352@api.kobiton.com/wd/hub"; DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session on iOS web"); capabilities.setCapability("sessionDescription", "This is example iOS web testing"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "safari"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "iPhone X"); capabilities.setCapability("platformVersion", "11.4.1"); capabilities.setCapability("platformName", "iOS"); RemoteWebDriver driver = new RemoteWebDriver(new URL(kobitonServerUrl), capabilities); /** * Prints Kobiton Session Id */ String kobitonSessionId = driver.getCapabilities().getCapability("kobitonSessionId").toString(); System.out.println("Your test session is: https://portal.kobiton.com/sessions/" + kobitonSessionId); driver.get("http://appium.io/"); System.out.println("Current URL is: " + driver.getCurrentUrl()); System.out.println("Title of page is: " + driver.getTitle()); /** * Goes to Appium page and prints URL & title */ driver.quit(); } }
Execute your Selenium Automation Script. You could find the result as mentioned below.
The result displays as below:
Kobiton Report:
To check the status of your automation test, click on the sessions tab. Now you can check the status of your automation test.
Kobiton makes your life easy when coming to mobile testing. If you already used Kobiton tool, share your experience by commenting below. If you never tried Kobiton then I highly recommend you to give it a try. Get your free trail of Kobiton Tool here.