German English
Start for free Log in Register
Language
German English

Mobile App Testing

Appium

Test your native apps and web apps with Appium on the devices of the Mobile Device Cloud

With Appium, you can create automated tests for your Android, iOS and web applications without having to make any changes to the applications.

All Selenium API-compatible programming languages are available for developing your tests.

The Appium driver provides you with the familiar Selenium environment on our mobile devices.

import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import org.junit.*;
import org.openqa.selenium.By;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;

public class LocaliOSTest {

    private String accessKey = "<ACCESS_KEY>";
    protected IOSDriver<IOSElement> driver = null;
    DesiredCapabilities dc = new DesiredCapabilities();

    @Before
    public void setUp() throws MalformedURLException {
        dc.setCapability("testName", "Quick Start iOS Native Demo");
        dc.setCapability("accessKey", accessKey);
        dc.setCapability("deviceQuery", "@os='ios' and @category='PHONE'");
        dc.setCapability(MobileCapabilityType.APP, "cloud:com.experitest.ExperiBank");
        dc.setCapability(IOSMobileCapabilityType.BUNDLE_ID, "com.experitest.ExperiBank");
        driver = new IOSDriver<>(new URL("https://mobiledevicecloud-test.t-systems-mms.eu/wd/hub"), dc);
    }

    @Test
    public void quickStartiOSNativeDemo() {
        driver.rotate(ScreenOrientation.PORTRAIT);
        driver.findElement(By.xpath("//*[@id='usernameTextField']")).sendKeys("company");
        driver.hideKeyboard();
        driver.findElement(By.xpath("//*[@id='passwordTextField']")).sendKeys("company");
        driver.findElement(By.xpath("//*[@id='loginButton']")).click();
        driver.findElement(By.xpath("//*[@id='makePaymentButton']")).click();
        driver.findElement(By.xpath("//*[@id='phoneTextField']")).sendKeys("0541234567");
        driver.findElement(By.xpath("//*[@id='nameTextField']")).sendKeys("Jon Snow");
        driver.findElement(By.xpath("//*[@id='amountTextField']")).sendKeys("50");
        driver.findElement(By.xpath("//*[@id='countryButton']")).click();
        driver.findElement(By.xpath("//*[@id='Switzerland']")).click();
        driver.findElement(By.xpath("//*[@id='sendPaymentButton']")).click();
        driver.findElement(By.xpath("//*[@id='Yes']")).click();
    }

    @After
    public void tearDown() {
        System.out.println("Report URL: "+ driver.getCapabilities().getCapability("reportUrl"));
        driver.quit();
    }
}

First steps with Appium

1.

Integrate Appium into your test framework

2.

Configure the connection to our Mobile Device Cloud API

3.

Install your apps with Appium

4.

Control your apps with Appium

1.
Integrate Appium into your test framework

Search in the list of Appium clients for your desired development language.

Follow the instructions of the repository to include the client.

2.
Configure the connection to our Mobile Device Cloud API

Before your tests, initialise an Appium driver that you can use later to control and automate elements of your app.

The driver needs two pieces of information:

  • The private access key to your project in the Mobile Device Cloud - you must copy this from your account
  • The URL to the Appium server of the Mobile Device Cloud - this is always the same and does not need to be changed by you (https://mobiledevicecloud-test.t-systems-mms.eu/wd/hub)
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("accessKey", "<ACCESS_KEY>");
IOSDriver<IOSElement> driver = new IOSDriver<>(new URL("https://mobiledevicecloud-test.t-systems-mms.eu/wd/hub"), dc);

It is best to build the driver in the setup() method of your tests and to close it in the teardown() method.

Use the example above as a guide.

3.
Install your apps with Appium

Upload your app to the Mobile Device Cloud and give the Appium driver the bundle ID of your app to launch it automatically.

dc.setCapability(MobileCapabilityType.APP, "cloud:<BUNDLE_ID>");

4.
Control your apps with Appium

Use the Appium driver methods to automate your app:

findElement(...)
sendKeys(...)
hideKeyboard()
rotate(...)
...
Appium + Jetpack Compose

Test your Android Jetpack Compose app with Appium on the Mobile Device Cloud devices

To test a Jetpack Compose app with Appium, the corresponding Espresso driver must be used.

The following description shows you the procedure:

import io.appium.java_client.AppiumBy;
import io.appium.java_client.android.AndroidDriver;
import org.junit.*;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;

public class EspressoTest {

    private final String CLOUD_ACCESS_KEY = "<ACCESS_KEY>";
    private final String APP_PATH = "cloud:<APP_BUNDLE_ID>";
    private final String ESPRESSO_SERVER= "<ESPRESSO_SERVER_UNIQUE_NAME>";
    protected AndroidDriver driver = null;
    private final DesiredCapabilities dc = new DesiredCapabilities();

    @Before
    public void setUp() throws MalformedURLException {
        dc.setCapability("accessKey", CLOUD_ACCESS_KEY);
        dc.setCapability("app", APP_PATH);
        dc.setCapability("espressoServerUniqueName", ESPRESSO_SERVER);

        dc.setCapability("platformName", "Android");
        dc.setCapability("automationName", "Espresso");
        dc.setCapability("deviceQuery", "@os='android' and @category='PHONE'");
        dc.setCapability("testName", "Quick Start Espresso Demo");
        dc.setCapability("appium:appiumVersion", "2.0.0.beta.23");

        driver = new AndroidDriver(new URL("https://mobiledevicecloud.t-systems-mms.eu/wd/hub"), dc);
        driver.setSetting("driver", "compose");
    }

    @Test
    public void quickStartEspressoDemo() {
        WebElement text = driver.findElement(AppiumBy.tagName("myTextTag"));
        Assert.assertEquals("Hello Espresso!", text.getText());
        driver.findElement(AppiumBy.tagName("myButtonTag")).click();

        driver.findElement(AppiumBy.tagName("myInputTag")).sendKeys("Mobile Device Cloud");
        driver.hideKeyboard();
        driver.findElement(AppiumBy.tagName("myInputButtonTag")).click();

        WebElement keywords = driver.findElement(AppiumBy.tagName("myKeywordsTag"));
        Assert.assertEquals("Mobile Device Cloud", keywords.getText());
    }

    @After
    public void tearDown() {
        System.out.println("Report URL: "+ driver.getCapabilities().getCapability("reportUrl"));
        driver.quit();
    }
}

First steps with Appium + Jetpack Compose

1.

Download demo project

2.

Install Espresso Driver

3.

Complete missing information

4.

Run setup

5.

Upload apps

6.

Start tests

1.
Download demo project

Download our Demo project and import it into your IDE for a smooth start.

2.
Install Espresso Driver

In addition to your app to be tested, a server app is also required for Espresso tests. This is built automatically by the Espresso driver for Appium. For this, you need to install a local Appium server. Download Node.js and NPM and install it.

Then install Appium 2 and the Espresso driver in the terminal using the following commands:

npm install -g appium@next
appium driver install espresso

Now start the Appium server with the command:

appium

The following messages should now appear:

  • Appium 2 was launched
  • The Espresso driver has been loaded
  • The REST interface is available
Mobile Device Cloud

3.
Complete missing information

Open the EspressoSetup.java File. In this file there are two placeholders that you have to fill:

<LOCAL_APPIUM_SERVER>: The URL to the REST interface of your local Appium server. This is displayed in the terminal when the server is started. (e.g. http://0.0.0.0:4723)

<APK_PATH>: The path to the APK file of your app that you previously generated with Android Studio. (Build → Build APK)

4.
Run setup

Start an emulator in Android Studio or connect a real Android device to your computer.

Start the EspressoSetup.java file either in run or debug mode. The setup is complete when the tests have run successfully.

During the setup, some information is displayed in the Appium Server terminal. This includes the line:

"Installing Espresso Test Server apk from the target device ..." with a path to the Espresso server APK. Copy this APK together with the APK of your app into a common folder to find them again later.

NOTE: The Espresso server depends heavily on your app. Therefore, it must always be rebuilt using the setup if dependencies in your app change.

Mobile Device Cloud

5.
Upload apps

Upload your app and the Espresso server to the Mobile Device Cloud.

Assign a unique name to the Espresso server.

6.
Start tests

Fill in the placeholders in the file MdcEspressoTest.java with your data.

Start the tests in Run or Debug mode. These are now executed in the Mobile Device Cloud.

You can use the examples to implement your own tests!

XCUITest

1. Remote debugging

Using remote debugging, you can run your XCUI tests in the Mobile Device Cloud as you would on a local device. To do this, download the remote debugging client:

  • for MacOS

and open a terminal in the client's folder.

Borrow a device in the Mobile Device Cloud and click on Tools → Remote Debugging. Copy the displayed command into the terminal and execute it. Now the device is displayed in XCode like a local device and can be used as such.

You will find detailed instructions here.

2. REST interface

Another way to run XCUI tests is via our REST interface.

To do this, generate an .ipa file for your app to be tested and a ZIP archive for your tests. You can find the exact steps here.

Pass the two files to our API:

curl --request POST \
  --url https://mobiledevicecloud.t-systems-mms.eu/api/v1/test-run/execute-test-run \
  --header 'Authorization: Bearer <accesskey>' \
  --header 'content-type: multipart/form-data' \
  --form 'executionType=xcuitest' \
  --form 'runningType=coverage' \
  --form 'testApp=@<Pfad zur Test-App>' \
  --form 'app=@<Pfad zur App>' \
  --form-string "deviceQueries=@os='ios'"

You can find documentation of the interface here.

Espresso

1. Remote debugging

Using remote debugging, you can run your Espresso tests in the Mobile Device Cloud as you would on a local device. To do this, download the remote debugging client:

  • for Windows
  • for MacOS

and open a terminal in the client's folder.

Borrow a device in the Mobile Device Cloud and click on Tools → Remote Debugging. Copy the displayed command into the terminal and execute it. Now the device is displayed in Android Studio like a local device and can be used as such.

You will find detailed instructions here.

2. REST interface

Another way to run Espresso tests is via our REST interface.

To do this, generate an APK file for your app to be tested and an APK file for your tests. You can find the exact steps here.

Pass the two APKs to our API:

curl --request POST \
  --url https://mobiledevicecloud.t-systems-mms.eu/api/v1/test-run/execute-test-run \
  --header 'Authorization: Bearer <accesskey>' \
  --header 'content-type: multipart/form-data' \
  --form 'executionType=espresso' \
  --form 'runningType=coverage' \
  --form 'testApp=@<Pfad zur Test-App>' \
  --form 'app=@<Pfad zur App>' \
  --form-string "deviceQueries=@os='android'"

You can find documentation of the interface here.

TestCafe

Test your web apps or browser apps with TestCafe on all browsers of the Mobile Device Cloud

The Mobile Device Cloud offers a plugin for the test tool TestCafe, which allows you to run your TestCafe tests on all desktop and mobile browsers of the Mobile Device Cloud.

import { Selector } from 'testcafe';

fixture('Getting Started with TestCafe')
    .page('https://devexpress.github.io/testcafe/example');

test('My first test', async t => {
    await t
        .typeText('#developer-name', 'MDC User')
        .click('#submit-button')
        .expect(Selector('#article-header').innerText).eql('Thank you, MDC User!');
});

First steps with TestCafe

1.

Contact us

2.

Set up plugin

3.

Start tests

1.
Contact us

The plugin for using TestCafe with the devices of the Mobile Device Cloud is still experimental.

Contact us to get access to the plugin and start working with TestCafe.

2.
Set up plugin

We support you with the installation of the necessary packages and configure them with you.

3.
Start tests

Write your tests with JavaScript in the familiar TestCafe environment.

With just one command, you can run the tests on a device of the Mobile Device Cloud:

Mobile Device Cloud
Tosca

The Mobile Device Cloud supports Tosca.

A documentation of the usage will follow soon.

Selenium

The Mobile Device Cloud supports Selenium.

A documentation of the usage will follow soon.