Skip to content
Martin Großmann edited this page Jul 31, 2024 · 11 revisions

Testerra-appium-connector

Dependencies

Include the following dependency in your project.

Gradle:

// Version from this module
implementation 'io.testerra:appium:2.4'
// Used Testerra version
implementation 'io.testerra:driver-ui:2.8'
implementation 'io.testerra:report-ng:2.8'
implementation 'io.appium:java-client:9.2.3'

Maven:

<!-- Version from this module -->
<dependency>
    <groupId>io.testerra</groupId>
    <artifactId>appium</artifactId>
    <version>2.4</version>
</dependency>
<!-- Used Testerra version -->
<dependency>
    <groupId>io.testerra</groupId>
    <artifactId>driver-ui</artifactId>
    <version>2.8</version>
</dependency>
<dependency>
    <groupId>io.testerra</groupId>
    <artifactId>report-ng</artifactId>
    <version>2.8</version>
</dependency>
<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>9.2.3</version>
    <!-- Needed for correct Testerra logging -->
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Use Appium features

The connector uses the AppiumDriver that you can use to unlock appium related features on the implementation of WebDriver interface.

Appium test class

import eu.tsystems.mms.tic.testframework.utils.AppiumUtils;
import org.openqa.selenium.ScreenOrientation;
...

public class ExampleTest extends TesterraTest implements WebDriverManagerProvider {

    @Test
    public void testT01_My_first_test() {

        WebDriver webDriver = WEB_DRIVER_MANAGER.getWebDriver();
        AppiumDriver appiumDriver = new AppiumUtils().getAppiumDriver(webDriver);
        // Use Appium driver specific methods
        appiumDriver.rotate(ScreenOrientation.LANDSCAPE);
    }
}

Properties

Basic configuration in test.properties

Property default Capability Description
tt.mobile.grid.url NONE - Grid URL of Appium / Selenium Grid ending on "wd/hub"
tt.mobile.grid.access.key NONE accessKey Access key of your user and project at Appium server, if needed.
tt.mobile.device.query.ios "@os='ios' and @category='PHONE'" deviceQuery Define the requested iOS device.
tt.mobile.device.query.android "@os='android' and @category='PHONE'" deviceQuery Define the requested Android device.

Device filtering

If you have to run your tests on specific mobile devices available on your mobile device farm, you can use the tt.mobile.device.query.android and tt.mobile.device.query.ios to filter for your devices by different properties. To reserve a device and run tests on it you can simply use WebDriverManager.getWebDriver() call. If one or more device(s) matches your filter, the driver will be instantiated, otherwise the call will fail.

The following query attributes are available for the device query strings.

  • @category
  • @os
  • @version
  • @manufacture
  • @model
  • @name

Please keep in mind, that you have to specify the device query for each operating system with the properties mentioned above. The default values will provide you a device with given operating system and of @category PHONE.

AppiumDriverRequest

You can also create new sessions by using the AppiumDriverRequest:

AppiumDriverRequest appiumRequest = new AppiumDriverRequest();
appiumRequest.setAccessKey(String);
appiumRequest.setDeviceQuery(String);
appiumRequest.setServerUrl(URL);

WebDriver appiumDriver = WEB_DRIVER_MANAGER.getWebDriver(appiumRequest);