• Stars
    star
    1,203
  • Rank 38,934 (Top 0.8 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol

java-client

Maven Central Javadocs Appium Java Client CI

This is the Java language bindings for writing Appium Tests that conform to WebDriver Protocol

v8 Migration

Since version 8 Appium Java Client had several major changes, which might require to update your client code. Make sure to follow the v7 to v8 Migration Guide in order to streamline the migration process.

Add Appium java client to your test framework

Stable

Maven

Add the following to pom.xml:

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>${version.you.require}</version>
  <scope>test</scope>
</dependency>

Gradle

Add the following to build.gradle:

dependencies {
  testImplementation 'io.appium:java-client:${version.you.require}'
}

Beta/Snapshots

Java client project is available to use even before it is officially published to maven central. Refer jitpack.io

Maven

Add the following to pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add the dependency:

<dependency>
    <groupId>com.github.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>latest commit ID from master branch</version>
</dependency>

Gradle

Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'com.github.appium:java-client:latest commit id from master branch'
}

Compatibility Matrix

Appium Java Client Selenium client
8.5.0 4.9.1
8.4.0 4.8.2, 4.8.3, 4.9.0
8.3.0 4.7.0, 4.7.1, 4.7.2, 4.8.0, 4.8.1
8.2.1 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.6.0

Why is it so complicated?

Selenium client does not follow Semantic Versioning, so breaking changes might be introduced even in patches, which requires Appium team to update Java client in response.

How to pin Selenium dependencies?

Appium Java Client declares Selenium dependencies using open version range which is handled in differently by different build tools. Sometimes users may want to pin used Selenium dependencies for various reasons. Follow the Transitive Dependencies Management article for more information about establishing a fixed Selenium version for your Java test framework.

Drivers Support

Appium java client has dedicated classes to support the following Appium drivers:

To automate other platforms that are not listed above you could use AppiumDriver or its custom derivatives.

Appium java client is built on top of Selenium and implements same interfaces that the foundation RemoteWebDriver does. However, Selenium lib is mostly focused on web browsers automation while Appium is universal and covers wide range of possible platforms, e.g. mobile and desktop operating systems, IOT devices, etc. Thus, the foundation AppiumDriver class in this package extends RemoteWebDriver with additional features, and makes it more flexible, so it is not so strictly focused on web-browser related operations.

Appium Server Service Wrapper

Appium java client provides a dedicated class to control Appium server execution. The class is AppiumDriverLocalService. It allows to run and verify the Appium server locally from your test framework code and provides several convenient shortcuts. The service could be used as below:

AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
service.start();
try {
    // do stuff with drivers
} finally {
    service.stop();
}

You could customize the service behavior, for example, provide custom command line arguments or change paths to server executables using AppiumServiceBuilder

Note

AppiumDriverLocalService does not support the server management on non-local hosts

Usage Examples

UiAutomator2

UiAutomator2Options options = new UiAutomator2Options()
    .setUdid('123456')
    .setApp("/home/myapp.apk");
AndroidDriver driver = new AndroidDriver(
    // The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
    new URL("http://127.0.0.1:4723"), options
);
try {
    WebElement el = driver.findElement(AppiumBy.xpath, "//Button");
    el.click();
    driver.getPageSource();
} finally {
    driver.quit();
}

XCUITest

XCUITestOptions options = new XCUITestOptions()
    .setUdid('123456')
    .setApp("/home/myapp.ipa");
IOSDriver driver = new IOSDriver(
    // The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
    new URL("http://127.0.0.1:4723"), options
);
try {
    WebElement el = driver.findElement(AppiumBy.accessibilityId, "myId");
    el.click();
    driver.getPageSource();
} finally {
    driver.quit();
}

Any generic driver that does not have a dedicated class

BaseOptions options = new BaseOptions()
    .setPlatformName("myplatform")
    .setAutomationName("mydriver")
    .amend("mycapability1", "capvalue1")
    .amend("mycapability2", "capvalue2");
AppiumDriver driver = new AppiumDriver(
    // The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
    new URL("http://127.0.0.1:4723"), options
);
try {
    WebElement el = driver.findElement(AppiumBy.className, "myClass");
    el.click();
    driver.getPageSource();
} finally {
    driver.quit();
}

Check the corresponding driver's READMEs to know the list of capabilities and features it supports.

You could find much more code examples by checking client's unit and integration tests.

Troubleshooting

InaccessibleObjectException is thrown in runtime if Java 16+ is used

Appium Java client uses reflective access to private members of other modules to ensure proper functionality of several features, like Page Object model. If you get a runtime exception and InaccessibleObjectException is present in the stacktrace, and your Java runtime is at version 16 or higher, then consider following Oracle's tutorial and/or checking existing issues for possible solutions. Basically, the idea there would be to explicitly allow access for particular modules using --add-exports/--add-opens command line arguments.

Another possible, but weakly advised solution, would be to downgrade Java to version 15 or lower.

Issues related to environment variables presence or to their values

Such issues are usually the case when Appium server is started directly from your framework code rather than run separately by a script or manually. Depending on the way the server process is started it may or may not inherit the currently active shell environment. That is why you may still receive errors about variables presence even though these variables ar actually defined for your command line interpreter. Again, there is no universal solution to that, as there are many ways to spin up a new server process. Consider checking the Appium Environment Troubleshooting document for more information on how to debug and fix process environment issues.

Changelog

Visit CHANGELOG.md to see the full list of changes between versions.

Running tests

Run a test using

gradle clean -Dtest.single=IOSAlertTest test

More Repositories

1

appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
JavaScript
18,666
star
2

appium-desktop

Appium Server in Desktop GUIs for Mac, Windows, and Linux
JavaScript
4,709
star
3

python-client

Python language bindings for Appium
Python
1,669
star
4

appium-inspector

A GUI inspector for mobile apps and more, powered by a (separately installed) Appium server
JavaScript
1,125
star
5

appium-xcuitest-driver

Appium iOS driver, backed by Apple XCTest
JavaScript
736
star
6

appium-docker-android

Appium Server setup to automate android testing on real devices
Shell
585
star
7

appium-uiautomator2-driver

Appium driver for Android UIAutomator2
JavaScript
558
star
8

appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
TypeScript
451
star
9

dotnet-client

Extension to the official Selenium dotnet webdriver
C#
381
star
10

appium-uiautomator2-server

Appium UiAutomator/UiObject2-based server for Android UI automation. This module is used by appium-uiautomator2-driver component
Java
326
star
11

appium-adb

Wrapper around adb used by appium + helper libs
JavaScript
273
star
12

appium-android-driver

Common methods collection used by Android drivers
JavaScript
249
star
13

android-apidemos

A fork of Google's Android ApiDemos application, used for testing Appium
Java
235
star
14

ruby_lib

💎 Ruby library for Appium
Ruby
216
star
15

appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Objective-C
193
star
16

appium-espresso-driver

Espresso integration for Appium
Kotlin
189
star
17

appium-doctor

[Deprecated] Please use https://github.com/appium/appium/tree/master/packages/doctor
JavaScript
128
star
18

appium-ios-device

Tools for interacting with iOS devices
JavaScript
126
star
19

appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Objective-C
124
star
20

io.appium.settings

App for dealing with Android settings
Java
121
star
21

appium-ios-simulator

Module for interacting with iOS simulators
JavaScript
97
star
22

appium-base-driver

Base class for an Appium driver
JavaScript
82
star
23

appium-idb

idb integration for Appium
JavaScript
75
star
24

ios-uicatalog

Apple UICatalog App
Objective-C
73
star
25

appium-chromedriver

Node.js wrapper around Chromedriver
JavaScript
66
star
26

mitmproxy-java

A bridge between Python's mitmproxy and Java programs. Built on top of mitmproxy-node
Java
64
star
27

node-simctl

Node wrapper around Apple's simctl binary
JavaScript
63
star
28

ruby_console

🎁 Appium Ruby Console
Ruby
45
star
29

appium-remote-debugger

Module for dealing with Remote Debugger protocol
JavaScript
44
star
30

appium_capybara

Gem enabling appium support in capybara
Ruby
40
star
31

appium-mac-driver

[deprecated] Mac application driver for Appium
JavaScript
36
star
32

ios-test-app

iOS app for testing
Objective-C
35
star
33

ruby_lib_core

Core library for the Ruby client
Ruby
34
star
34

selenium-swift

selenium bindings for the swift programming language
Swift
33
star
35

node-teen_process

A slightly more grown-up version of Node's child_process
JavaScript
27
star
36

node-adb-client

A direct-to-device ADB client implementation in Node
JavaScript
27
star
37

appium-safari-driver

Safari browser support for Appium
JavaScript
24
star
38

appium.io

[deprecated] The public front-end for Appium
CSS
21
star
39

appium-support

Support libs used across appium packages.
JavaScript
17
star
40

appium-chromium-driver

An Appium driver for the Chrome browser
JavaScript
17
star
41

appium-xcode

Xcode related utilities. Get version number and path to executable.
JavaScript
16
star
42

appium-geckodriver

Support for Geckodriver (Firefox driver) within Appium
JavaScript
15
star
43

sample-apps

Sample app manager, for testing
JavaScript
14
star
44

VodQAReactNative

Sample react native app demoing components and gestures
JavaScript
10
star
45

screenshooter

Screenshot application for Android
Java
10
star
46

appium-fake-driver

A fake Appium driver used for testing and demonstration
JavaScript
8
star
47

droiddriver_examples

Java
6
star
48

DynamicApp

Titanium app generating random code + command injector.
JavaScript
6
star
49

appium-gulp-plugins

Custom plugins used across appium modules
JavaScript
5
star
50

dump2json

Converts UIAutomator XML dump to JSON for Appium.
Java
5
star
51

io.appium.gappium.sampleapp

Appium Sample App for Cordova Test Automation (Gappium)
JavaScript
5
star
52

appium-test-support

A collection of test utility lib used across Appium packages
JavaScript
4
star
53

appium-build-store

Temporary store for Appium builds, for sub-package CI systems
4
star
54

gps-demo-app

Android GPS demo from http://www.impressive-artworx.de/tutorials/android/gps_tutorial_1.zip
Java
4
star
55

appium-event-parser

Node CLI script to help parse event timing output from Appium scripts
JavaScript
4
star
56

appium-gui-libs

Code shared between various Appium GUI projects (Appium Desktop Server, Appium Inspector)
JavaScript
4
star
57

perl-client

Perl
3
star
58

workshop

To be used when people do Appium workshops
JavaScript
3
star
59

clean_apk

APK used to clean up between tests for Appium.
Java
3
star
60

eslint-config-appium

Shared configuration for ESLint
JavaScript
3
star
61

python-client-sphinx

Docs repo for Appium Python Client
3
star
62

worms

Issue tracker for Apple bugs affecting Appium
2
star
63

appium-ios

iOS-specific packages for Appium
JavaScript
2
star
64

ios-webview-app

Webview app for testing appium
Objective-C
2
star
65

blog

A GH powered Appium blog
1
star
66

dmg-template

dmg template for building appium-dot-app
Objective-C
1
star
67

appium.github.com

Appium.io
JavaScript
1
star
68

ios

Appium mono repo containing iOS specific packages.
1
star
69

appium_thor

Appium Thor helpers for appium's gems
Ruby
1
star
70

appiumlogs

Logs from the #appium IRC channel on freenode.net
Shell
1
star
71

packweb

Tools for maintaining projects with large numbers of packages
JavaScript
1
star
72

appium-package-master

A set of tools to create and manage appium packages.
JavaScript
1
star
73

jobs

Appium job board
1
star
74

test_runner

Ruby test runner for Appium
Ruby
1
star
75

appium-benchmarks

A suite of exercises designed to evaluate the performance of an Appium server or service
TypeScript
1
star