Run Test on iPad device using Kobiton Cloud
Overview
In this tutorial, we will run a test on the iPad device using Kobiton Cloud. We need to set the appropriate capabilities for the iPad device to test. Device name, version numbers, deviceOrientation mode, etc.
DesiredCapabilities
Sample DesiredCapabilities for the iPad device on the cloud.
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session"); capabilities.setCapability("sessionDescription", ""); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "safari"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "iPad (6th generation)"); capabilities.setCapability("platformVersion", "13.4.1"); capabilities.setCapability("platformName", "iOS");
Sample Test
package com.testingdocs.appium.quickstart.AppiumProject; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.Assert; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.ios.IOSElement; /** * Cloud Test. */ public class KobitonCloudiPadTest{ public static final String USERNAME = "TestingDocs007"; public static final String ACCESS_KEY = "7d60183d-f9d7-4d21-b9c9-52a3e69040c5"; public static final String URL = "https://"+USERNAME+":" + ACCESS_KEY + "@api.kobiton.com/wd/hub"; public static IOSDriver<IOSElement> mDriver; @BeforeTest public void beforeTest( ) throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "iPad session"); capabilities.setCapability("sessionDescription", ""); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "safari"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "iPad (6th generation)"); capabilities.setCapability("platformVersion", "13.4.1"); capabilities.setCapability("platformName", "iOS"); mDriver = new IOSDriver<IOSElement>(new URL(URL), capabilities); } @AfterTest public void afterTest( ){ mDriver.quit(); } @Test public static void launchSafariBrowser(){ mDriver.get("https://www.testingdocs.com/"); mDriver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); Assert.assertEquals(mDriver.getTitle(), "Home | TestingDocs", "Check Title"); } }
Run the test. Right-click on the test and Run As >> TestNG Test.
Screenshot
Appium Tutorials:
https://www.testingdocs.com/appium-tutorials/
For more information on Appium Tool:
http://appium.io/