Running Appium Scripts
  • 16 Aug 2024
  • 5 Minutes to read
  • Dark
    Light

Running Appium Scripts

  • Dark
    Light

Article summary

Overview

Appium is a popularly used open source test automation framework that helps with automating mobile app testing of both iOS and Android Apps. You can integrate your appium scripts on pCloudy, as we have extended support to Appium Automation.

There are different ways in which you can enable appium automation on pCloudy. One, is if you already have your Appium Scripts in Java you can use the pCloudy-java-connector.jar to integrate it on the pCloudy platform. However, in case you don’t have your Appium script then or haven't created it yet, you can use the rest APIs available on our API Documentation.

Objective of this document

This objective of this document is to help you integrate your appium test scripts on the pCloudy platform to execute various automated app tests parallely.

Pre-requisites

  • Appium Script
  • APK or IPA file
  • pCloudy Account

Important: Before we integrate the appium scripts on pCloudy, we'll first need to generate the API access key. As this will needed for the integration process.

Steps to get the API key

  1. Login to your registered account on device.pcloudy.com
  2. Click on Profile at the top right corner of the screen.
  3. You can find your API access key here. You can copy the same or click on Regenerate to get a new one.

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.

Option 1 - Using pCloudy Appium Capabilities

Steps to replace your local Appium driver to pCloudy Appium Driver using pCloudy Appium capabilities are given below:

  1. Upload the APK/IPA from your local system to pCloudy.
  2. Set pCloudy capabilities

  • pCloudy_Username: Enter the email ID with which you have registered on pCloudy.
    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.
    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", 10);

  • 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");

capabilities.setCapability("newCommandTimeout", 600); capabilities.setCapability("launchTimeout", 90000);
capabilities.setCapability("appPackage", "com.pcloudy.appiumdemo");
capabilities.setCapability("appActivity", "com.ba.mobile.LaunchActivity");

Note: If the device full name is not known please use pCloudy_DeviceManufacturer or/and pCloudy_DeviceVersion.

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


  1. Use pCloudy Appium endpoint as “https://device.pcloudy.com/appiumcloud/wd/hub”
  2. Create the Appium driver object and perform the execution

Device capabilities and code snippets to run Appium for a native app on a single Android device:


@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");

Below is a XML Code Snippet
image.png

Device capabilities and code snippets to run Appium for a native Apps on multiple Android devices:

@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", 10);
    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");

image.png

Device capabilities and code snippets to run Appium for a native App on a single iOS device:

@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", 10);
    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");

image.png

Device capabilities and code snippets to run Appium for a native app on multiple iOS devices:

@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", 10);
    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");

image.png

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", 10);
    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");

image.png

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", 10);
    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");

image.png

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", 10);
    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");

image.png

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", 10);
    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");

image.png

Option 2 - Using APIs

Steps to replace your local Appium driver to pCloudy Appium Driver using pCloudy APIs capabilities -

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

Generating Appium Capabilities integration with Pcloudy

Option 3 - Using 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.


Was this article helpful?