Appium

Prerequisites

  • Devices using Chrome 65 or later

Upload Application for Appium

Upload the app to GigaFox and use the bundleId (iOS) or appPackage and appActivity capabilities, per Appium documentation, to direct launch the app. GigaFox will install the app using its own content storage system and install code, enforcing ACLs as relevant.

GigaFox Capabilities

Key Required Description
gigafox:username Required The GigaFox username for authentication.
Example:
"gigafox:username": "John.Smith@company.com"
gigafox:apiKey Required The users API token for authentication.
Example:
"gigafox:apiKey": "bca2e6ae-d0c2- 4833-9fcd-944607644a5"
gigafox:device Required The GigaFox device ID for the device.
Example:
"gigafox:device": "69498336-2a30- 4a42-b837-6d453f3a153b"
gigafox:application Required The name of the application to launch.
Example:
"gigafox:application": "deviceControl"
gigafox:applicationVersion Optional Can specify the application by its version.
Example:
"gigafox:applicationVersion": "3.0.1"
gigafox:skipResigning Enabled by default Set to true by default, gigafox:skipResigning prevents Trust instrumentation libraries from loading on the application.
Example:
"gigafox:skipResigning": "true"
gigafox:skipInstall Optional By default, Appium reinstalls an application each time a session is created. gigafox:skipInstall will skip the installation process, allowing a device to test with previously saved application data and avoiding the need to grant application permissions for every session.
gigafox:skipInstall will launch applications that are already installed on a device, but not in the GigaFox application list. Example:
"gigafox:skipInstall": "true"
"gigafox:ignoreSession" Enabled by default If an existing Appium session has disconnected but is trying to re-establish the connection, gigafox:ignoreSession will kill that session allowing a new session to start. If set to false, Appium will go through the process of trying to reconnect multiple times and will not allow a new session to start until the existing connection fails.
Example:
"gigafox:ignoreSession": "true"
gigafox:chromeDeviceVerbose Optional Enable verbose ChromeDriver logging on Appium logs.
Example:
"gigafox:chromeDeviceVerbose": "true"
gigafox:sessionName Optional Assigns a name to the Appium session which can be used for future reference. When set, the assigned gigaFox:sessionName is displayed inside of the historical Appium session logs.
Example:
"gigafox:sessionName": "Appium Test 1"

DesiredCapabilities augmented by GigaFox

Key Required Description
bundleId Required (iOS) The iOS application’s bundle identifier. The latest version managed by GigaFox is used.
Example: "bundleID": "com.mobilelabsinc.Trust-Browser"
appPackage Required (Android) The Android application’s package name.
Example: "appPackage": "com.mobilelabsinc.trustbrowser"
appActivity Required (Android) The Android application’s activity name to launch. appPackage and appActivity are used together to locate the latest version of the application managed by GigaFox.
Example: "appActivity": "com.mobilelabsinc.trustbrowser"
Default: Exclude to perform native browser testing. browserName must be specified when excluded.
browserName Optional The name of the native web browser to use. Must be "Safari" on iOS or "Chrome", "Chromium", or "Browser" on Android.
Example: "browserName": "Safari"
Default: Exclude to perform application test. bundleId (iOS) or appPackage/ appActivity (Android) must be specified when excluded.
automationName Optional Set to XCUITest for testing devices using XCTest, otherwise no value should be set. XCTest is required for iOS 10 and later.
Example: "automationName": "XCUITest"
version Optional For Selenium Grid users, the version capability will exactly match the device's OS version.
Example: "version": "12.3.1"

NOTE: The following capabilities are automatically managed by GigaFox and cannot be used: xcodeConfigFile, realDeviceLogger, app, and keychainPath.

For more information on DesiredCapabilities, go to Appium’s DesiredCapabilities documentation.

GigaFox Device ID

The GigaFox ID for a device is located in the URL of the device’s details page.

GigaFox Application ID

The GigaFox application ID is located in the URL of the application’s details page.

Automatic device selection

If gigafox:device is not specified, then GigaFox automatically selects a device.

For a device to be selected, the following conditions must be true:

  1. Is not retained/in-use.
  2. Regarding the application:
    1. The device’s operating system matches the application’s (iOS or Android).
    2. The device’s operating system version is at least the application’s minimum supported version.
    3. If the application is for an iOS device and not universal, the device must be an iPad or iPhone as specified.
  3. If platformVersion is specified, the device’s OS version must match exactly.

Integration test examples

A Java sample of how to use GigaFox with Appium integration:


   import io.appium.java_client.ios.IOSDriver;

   import org.openqa.selenium.WebElement;
   import org.openqa.selenium.remote.DesiredCapabilities;
   import java.net.URL;

   public class AppiumTest {
     // The hostname or IP address used to connect to GigaFox.
     public static final string gigafoxHost = "gigafox.yourcompany.com";

     // The user’s GigaFox login email address.
     public static final string gigafoxUsername = "user@yourcompany.com";

     // The user’s API token. The API token can be found by clicking the user
     // name menu in the upper right of GigaFox, selecting
     // "Manage your account", then select View Token.
     public static final string gigafoxApiKey = "bca2e6ae-d0c2-4833-9fcd-9446076442a5";

     private static final String serviceUrl =
     "http://" + gigafoxHost + "/Appium";

     public static void IOSSafariExample() {
       DesiredCapabilities capabilities = new DesiredCapabilities();

     // The name of a web browser to test on. Possible values are Safari or
     // Chrome. If no device is specified, an
     // appropriate iOS or Android device will be chosen automatically.
     capabilities.setCapability("gigafox:browserName", "Safari");
     capabilities.setCapability("gigafox:automationName", "XCUITest");
     capabilities.setCapability("gigafox:username", gigafoxUsername);
     capabilities.setCapability("gigafox:apiKey", gigafoxApiKey);

     IOSDriver driver = null;

     try {
       URL url = new URL(serviceUrl);
       driver = new IOSDriver(url, capabilities);

         driver.navigate().to("http://www.google.com");
       WebElement searchBox =
       driver.findElementByCssSelector("input[type=text]");
       WebElement googleSearchButton =
       driver.findElementByCssSelector("input[type=submit]");

       searchBox.sendKeys("Hello World!");
       googleSearchButton.click();
     } catch (Exception e) {
         System.out.println("Error performing Appium test: " + e.getMessage());
         e.printStackTrace();
     } finally {
         if (driver != null) {
           driver.close();
        }
     }
   }
   public static void IOSHybridApplicationExample() {
     DesiredCapabilities capabilities = new DesiredCapabilities();
     // GigaFox will select the latest version of this application from
     // the applications list. Because it is an iOS application and no device
     // is specified, an appropriate iOS device will be selected automatically.
     capabilities.setCapability("bundleId", "com.mobilelabsinc.Trust-Browser");
     capabilities.setCapability("gigafox:automationName", "XCUITest");
     capabilities.setCapability("gigafox:username", gigafoxUsername);
     capabilities.setCapability("gigafox:apiKey", gigafoxApiKey);

     IOSDriver driver = null;

     try {
        URL url = new URL(serviceUrl);
        driver = new IOSDriver(url, capabilities);
        // Find and click on a native element.
        WebElement nativeElement = driver.findElementByName("nativeElementName");
        nativeElement.click();
        // Switch contexts to the WebView, then find and click on an element.
        driver.context("WEBVIEW_1");
        WebElement webElement = driver.findElementByName("webElementName");
        webElement.click();
    } catch (Exception e) {
        System.out.println("Error performing Appium test: " + e.getMessage());
        e.printStackTrace();
    } finally {
        if (driver != null) {
            driver.close();
      }
     }
    }
   }
    

Appium Inspector

GigaFox's Appium Inspector is used to identify the visual elements with the hierarchical layout information on a device's screen. More information can be found on this guide's Appium Inspector page.

Appium Logs

To view Appium logs on the web:

  1. Navigate to the device's detail page..
  2. Click the ... button and View Appium Logs.

Appium Log Export

To download Appium logs, go to the System Logs and enable Report Appium Issue

Appium Documentation

For Appium concepts, explanations, and test samples go to Appium’s documentation.