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();
}
}
1.
2.
3.
4.
Search in the
Follow the instructions of the repository to include the client.
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:
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.
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>");
Use the Appium driver methods to automate your app:
findElement(...)
sendKeys(...)
hideKeyboard()
rotate(...)
...
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();
}
}
1.
2.
3.
4.
5.
6.
Download our
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
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:
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)
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.
Upload your app and the Espresso server to the Mobile Device Cloud.
Assign a unique name to the Espresso server.
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!
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:
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
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
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
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:
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
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
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
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!');
});
1.
2.
3.
The plugin for using TestCafe with the devices of the Mobile Device Cloud is still experimental.
We support you with the installation of the necessary packages and configure them with you.
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:
The Mobile Device Cloud supports Tosca.
A documentation of the usage will follow soon.
The Mobile Device Cloud supports Selenium.
A documentation of the usage will follow soon.