Running Appium Scripts

Appium is an open source test automation framework which is used with wide range of mobile apps that supports only android/ios or both. pCloudy is a popular mobile testing platform integrated with Appium script which enables you to automate test of mobile apps as well. If you have your Appium Scripts (or you plan to build them) in Java then you can use the pCloudy-java-connector.jar to integrate with the pCloudy platform. In case, you don’t have your Appium script then, you will need to use the rest APIs from here.

Objective of this document

This help guide will help you to understand the APIs that pCloudy platform provides to integrate your existing Appium Scripts with pCloudy. After the integration, you will be able to execute your Appium scripts from your PC directly to the pCloudy real device cloud.

Pre-requisites

  • Appium Script
  • >APK or IPA file
  • pCloudy Account

Steps to get the API key

Step 1: Login to your registered account on device.pcloudy.com

Step 2: Click on your name given at the top right corner of the screen and click on Settings

Settings

Step 3: You can find your API access key here. You can copy the same or click on Regenerate to get a new one.

API access key

Integrating pCloudy with your Appium project:

You can integrate your Appium project with pCloudy using 3 different methods. Click on each option to know more about them.

Using pCloudy Appium Capabilities

The basic steps to replace your local Appium driver to pCloudy Appium Driver using pCloudy Appium capabilities are given below:

 

  • Upload the apk/ipa from your local system to pCloudy. Check this link to know steps to upload an app for test.
  • Set pCloudy capabilities
    • pCloudy_Username: Enter the email ID with which you have registered on pCloudy. For reference, check this link

      Example: capabilities.setCapability("pCloudy_Username", '{e-mail-id}');

    •  

    • pCloudy_ApiKey: API key is important for user's verification. You can generate the API key from Settings page on device.pcloudy.com. Check this link to get your API key.

      Example: capabilities.setCapability("pCloudy_ApiKey", "{api-key}");

    •  

    • pCloudy_ApplicationName: Enter the application name for the apk/ipa file which you already uploaded in the MyApp/Data.

      Example: capabilities.setCapability("pCloudy_ApplicationName", "pCloudyAppiumDemo.apk");

    •  

    • pCloudy_DurationInMinutes: Enter the duration in minutes for which you want to run the test.

      Example: capabilities.setCapability("pCloudy_DurationInMinutes", 5);

    •  

    • pCloudy_DeviceFullName: If you know the device manufacturer, device name and version then enter the full device name.

      Example: capabilities.setCapability("pCloudy_DeviceFullName", "Samsung_GalaxyTabA_Android_7.1.1");

      Note: If you don't know the Device full name then you can enter pCloudy_DeviceManufacturer and pCloudy_DeviceVersion in the code and it will automatically run command on those devices.

      Example: capabilities.setCapability("pCloudy_DeviceManafacturer", "Samsung");

      capabilities.setCapability("pCloudy_DeviceVersion", "5.0.1");
    •  

  • Use pCloudy Appium endpoint as “https://device.pcloudy.com/appiumcloud/wd/hub”
  • Create the Appium driver object and perform the execution
Device capabilities and code snippets to run Appium on Single Android Native App:

@BeforeMethod
public void prepareTest() throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email Id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your API Key");
capabilities.setCapability("pCloudy_ApplicationName", "pCloudyAppiumDemo.apk");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceFullName", "Samsung_GalaxyTabA_Android_7.1.1");
driver = new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceManafacturer", "Samsung");
capabilities.setCapability("pCloudy_DeviceVersion", "5.0.1");

Code 1

Device capabilities and code snippets to run Appium on Multiple Android Native Apps:

@Parameters({ "deviceName" })
@BeforeMethod
public void prepareTest(String deviceName) throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email Id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your API Key");
capabilities.setCapability("pCloudy_ApplicationName", "pCloudyAppiumDemo.apk");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceManafacturer", deviceName);
driver = new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceVersion", "5.0.1");
capabilities.setCapability("pCloudy_DeviceFullName", "Samsung_GalaxyTabA_Android_7.1.1");

Code 2

Device capabilities and code snippets to run Appium on Single iOS Native Apps:

@BeforeMethod
public void prepareTest() throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email Id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your API Key");
capabilities.setCapability("pCloudy_ApplicationName", "TestmunkDemo.ipa");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceFullName", "Apple_iPhone6S_Ios_11.2.0");
driver = new IOSDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceManafacturer", "Apple");
capabilities.setCapability("pCloudy_DeviceVersion", "10.3.2");

Code 3

Device capabilities and code snippets to run Appium on Multiple iOS Native Apps:

@Parameters({ "deviceName" })
@BeforeMethod
public void prepareTest(String deviceName) throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email-id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your APIKey");
capabilities.setCapability("pCloudy_ApplicationName", "TestmunkDemo.ipa");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceManafacturer", deviceName);
driver = new IOSDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceVersion", "10.3.2");
capabilities.setCapability("pCloudy_DeviceFullName", "Apple_iPhone6S_Ios_11.2.0");

Code 4

Device capabilities and code snippets to run on Single iOS-Browser App:

@BeforeMethod
public void prepareTest() throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email-id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your APIKey");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceFullName", "Apple_iPhone6S_Ios_11.2.0");
capabilities.setBrowserName("Safari");
driver = new IOSDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceManafacturer", "Apple");
capabilities.setCapability("pCloudy_DeviceVersion", "10.3.2");

Code 5

Device capabilities and code snippets to run on Multiple iOS-Browser App:

@Parameters({ "deviceName" })
@BeforeMethod
public void prepareTest(String deviceName) throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email-id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your APIKey");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceManafacturer", deviceName);
capabilities.setBrowserName("Safari");
driver = new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceVersion", "10.3.2");
capabilities.setCapability("pCloudy_DeviceFullName", "Apple_iPhone6S_Ios_11.2.0");

Multiple Browser App

Device capabilities and code snippets to run on Single Android-Browser App:

@BeforeMethod
public void prepareTest() throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email-id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your APIKey");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceManafacturer", "Samsung");
capabilities.setBrowserName("Chrome");
driver = new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceVersion", "5.0.1");
capabilities.setCapability("pCloudy_DeviceFullName", "Samsung_GalaxyTabA_Android_7.1.1");

Single Android Browser App

Device capabilities and code snippets to run on Multiple Android-Browser Apps:

@Parameters({ "deviceName" })
@BeforeMethod
public void prepareTest(String deviceName) throws IOException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("pCloudy_Username", "Enter your email-id");
capabilities.setCapability("pCloudy_ApiKey", "Enter your APIKey");
capabilities.setCapability("pCloudy_DurationInMinutes", 5);
capabilities.setCapability("pCloudy_DeviceManafacturer", deviceName);
capabilities.setBrowserName("Chrome");
driver = new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), capabilities);
}
Note: Capabilities mentioned below are optional:
capabilities.setCapability("pCloudy_DeviceVersion", "5.0.1");
capabilities.setCapability("pCloudy_DeviceFullName", "Samsung_GalaxyTabA_Android_7.1.1");

Multiple Android Browser App

 

Use APIs

The basic steps to replace your local Appium driver to pCloudy Appium Driver using pCloudy APIs capabilities are given below:

 

  • Authenticate the pCloudy token to get an auth token
  • Get the list of device(s)
  • Book the device(s)
  • Upload the apk/ipa from your local system or get the apk/ipa from pCloudy My app/data
  • Get the Appium endpoint
  • Create the Appium driver object and perform execution
  • Get the consolidated report

Architecture for Appium integration with pCloudy

Please have a look at the video to understand Appium integration with pCloudy.

Use pre-built connectors

Following are relevant links to download the connectors and sample projects:

 

Java- Appium Integration:

Appium - Dotnet Integration: https://github.com/pankyopkey/pCloudy-sample-projects/tree/master/DotNet

Appium TestNG Integration with Extent report: https://github.com/pankyopkey/pCloudy-sample-projects/tree/master/Java/Advanced(Continued...)

Python - Appium Integration: https://github.com/pankyopkey/pCloudy-sample-projects/tree/master/Python/AndroidNative

Ruby - Appium Integration: https://github.com/pankyopkey/pCloudy-sample-projects/tree/master/Ruby

Visit https://github.com/pankyopkey/pCloudy-sample-projects. This repository contains the Appium Sample Projects for quick beginners and advanced learners covering almost all the scenarios.