랭킹으로 돌아가기

appium/java-client

Java

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

javajava-clientseleniumandroidappiumautomationioswindowsmacos
스타 성장
스타
1.3k
포크
756
주간 성장
이슈
269
5001k
2014년 4월2018년 5월2022년 6월2026년 7월
아티팩트Mavengit clone https://github.com/appium/java-client.git
README

java-client

Maven Central Version Javadocs Appium Java Client CI

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

v9 to v10 Migration

Follow the v9 to v10 Migration Guide to streamline the migration process.

v8 to v9 Migration

Since v9 the client only supports Java 11 and above. Follow the v8 to v9 Migration Guide to streamline the migration process.

v7 to 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 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 to 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
10.1.1 4.42.0, 4.43.0
10.1.0 4.40.0, 4.41.0
10.0.0 4.35.0, 4.36.0, 4.37.0, 4.38.0, 4.39.0
9.5.0 4.34.0
9.4.0 4.26.0, 4.27.0, 4.28.0, 4.28.1, 4.29.0, 4.30.0, 4.31.0, 4.32.0, 4.33.0
9.2.1(known issues: appium/java-client#2145, appium/java-client#2146), 9.2.2, 9.2.3, 9.3.0 4.19.0, 4.19.1, 4.20.0, 4.21.0, 4.22.0, 4.23.0, 4.23.1, 4.24.0, 4.25.0, 4.26.0, 4.27.0
9.1.0, 9.2.0 4.17.0, 4.18.0, 4.18.1
9.0.0 4.14.1, 4.15.0, 4.16.0 (partially corrupted), 4.16.1
N/A 4.14.0
8.5.0, 8.5.1, 8.6.0 4.9.1, 4.10.0, 4.11.0, 4.12.0, 4.12.1 (known issue: appium/java-client#2004), 4.13.0
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 the Appium team to update the Java client in response.

How to pin Selenium dependencies?

Appium Java Client declares Selenium dependencies using an open version range which is handled 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 the same interfaces that the foundation RemoteWebDriver does. However, Selenium lib is mostly focused on web browser automation while Appium is universal and covers a 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 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 URI("http://127.0.0.1:4723").toURL(), 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 URI("http://127.0.0.1:4723").toURL(), 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 URI("http://127.0.0.1:4723").toURL(), 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 can find many 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 the Page Object model. If you get a runtime exception and InaccessibleObjectException is present in the stack trace and your Java runtime is at version 16 or higher, then consider the following Oracle's tutorial and/or checking existing issues for possible solutions. 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.

Such issues are usually the case when the 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 the variables' presence even though these variables are 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

관련 저장소
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

algorithmleetcode
cyc2018.xyz
184.8k50.8k
Snailclimb/JavaGuide

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

JavaScriptnpmApache License 2.0javainterview
javaguide.cn
157.2k46.2k
iluwatar/java-design-patterns

Design patterns implemented in Java

JavaMavenOtherjavaprinciples
java-design-patterns.com
94.2k27.4k
Stirling-Tools/Stirling-PDF

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

JavaMavenOtherdockerjava
stirling.com
87.7k7.8k
macrozheng/mall

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于Spring Boot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

JavaMavenApache License 2.0spring-bootspring-security
macrozheng.com/admin/
84.3k29.8k
spring-projects/spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.

JavaMavenApache License 2.0javaspring-boot
spring.io/projects/spring-boot
81.1k42k
doocs/advanced-java

😮 Core Interview Questions & Answers For Experienced Java(Backend) Developers | 互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识

JavaMavenCreative Commons Attribution Share Alike 4.0 Internationaljavadistributed-systems
java.doocs.org
79k19.2k
elastic/elasticsearch

Free and Open Source, Distributed, RESTful Search Engine

JavaMavenOtherelasticsearchjava
elastic.co/products/elasticsearch
77.6k26.1k
TheAlgorithms/Java

All Algorithms implemented in Java

JavaMavenMIT Licensejavaalgorithms
66k21.2k
kdn251/interviews

Everything you need to know to get the job.

JavaMavenMIT Licensejavainterview
youtube.com/channel/UCKvwPt6BifPP54yzH99ff1g
65.1k12.9k
youngyangyang04/leetcode-master

《代码随想录》LeetCode 刷题攻略:200道经典题目刷题顺序,共60w字的详细图解,视频难点剖析,50余张思维导图,支持C++,Java,Python,Go,JavaScript等多语言版本,从此算法学习不再迷茫!🔥🔥 来看看,你会发现相见恨晚!🚀

Shellleetcodeprogrammer
62k12.3k
azl397985856/leetcode

LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)

JavaScriptnpmOtheralgorithmleetcode
leetcode-solution-leetcode-pp.gitbook.io/leetcode-solution/
55.8k9.4k