Appium is an open-source, cross-platform tool for automating mobile app testing. If your team has existing Appium tests, they can be integrated with HeadSpin and run on any HeadSpin device you have access to. Using Appium Desktop you can inspect the view hierarchy of an application, determine the selectors, and even generate scaffold Appium code.
Note: The API calls in this guide will be expressed as cURL commands for ease of readability cross-platform and independent of programming language.
Automation Configuration API
The HeadSpin Automation Configuration API provides you with the optimal minimum Desired Capabilities to use for a given device and the WebDriver URL. To recap, Desired Capabilities tell Appium how you want your test to work. They are represented as keys and associated values encoded in a JSON object and sent by the Appium client to the Appium server.
The <code class="dcode">capabilities</code> object will have the values for your Desired Capabilities. The <code class="dcode">driver_url</code> will be the remote WebDriver you will use in your test.
Launching your application
In addition, the the minimum Desired Capabilies, the last remaining item to specify is the app you want to test.
Android
For a given Android application you will need to specify the <code class="dcode">appPackage</code> and <code class="dcode">appActivity</code> you would like to launch. The appPackage is the Android app that you want to run and the <code class="dcode">appActivity</code> is the specific activity within the Android app package you would like to launch.
The starting <code class="dcode"><manifest></code> tag includes the <code class="dcode">appPackage</code> name and the <code class="dcode"><activity></code> tags show the activities of your app.
In the event where you don't have project source, you can determine this via <code class="dcode">adb.</code> If you install your app on your HeadSpin Device, launch it, and then use <code class="dcode">adb shell</code> either via the HeadSpin Remote ADB or REST API, you can run:
dumpsys window windows | grep -E ‘mCurrentFocus’
This will return the information in the following format: <code class="dcode">(appPackage/appActivity)</code>
iOS
For iOS you will need to specify the bundleId of the application. If you have .xcodeproj or .xcworkspace source then you can determine this from the General section in the Project Information section in Xcode:
In the event where you don't have project source, you can determine this from the iOS REST API to retrieve a list of installed apps on a given device. Please refer to the iOS Device API guide.
Examples in Appium Client Languages
The reference code snippets below provide a visual reference to how the desired capabilities and remote driver URL syntax appear in different Appium Client languages.
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SampleTest {
private AndroidDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("udid", "{device-id}");
desiredCapabilities.setCapability("deviceName", "{device-id}");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("appPackage", "io.headspin.example");
desiredCapabilities.setCapability("appActivity", "io.headspin.example.LauncherActivity");
desiredCapabilities.setCapability("automationName", "UiAutomator2");
desiredCapabilities.setCapability("noReset", true);
desiredCapabilities.setCapability("autoAcceptAlerts", true);
URL remoteUrl = new URL("https://proxy-us-sf-3.headspin.io:7003/v0//wd/hub");
driver = new AndroidDriver(remoteUrl, desiredCapabilities);
}
@After
public void tearDown() {
driver.quit();
}
}
HeadSpin Appium Capabilities
HeadSpin also provides a set of convenient Appium Capabilities for using certain platform features such as Performance Sessions or setting a specific Appium Server version for example. The full listing of capabilities can be found in the HeadSpin Appium Capabilities document.