Skip to content

Commit e0ab871

Browse files
docs: Update readme and remove obsolete documents (#1792)
1 parent 57ce03b commit e0ab871

8 files changed

+153
-535
lines changed

README.md

Lines changed: 150 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,48 @@
44
[![Javadocs](https://www.javadoc.io/badge/io.appium/java-client.svg)](https://www.javadoc.io/doc/io.appium/java-client)
55
[![Build Status](https://travis-ci.org/appium/java-client.svg?branch=master)](https://travis-ci.org/appium/java-client)
66

7-
This is the Java language binding for writing Appium Tests, conforms to [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)
7+
This is the Java language bindings for writing Appium Tests that conform to [WebDriver Protocol](https://w3c.github.io/webdriver/)
88

9-
[API docs](https://www.javadoc.io/doc/io.appium/java-client)
9+
## v8 Migration
1010

11-
### Features and other interesting information
11+
Since version 8 Appium Java Client had several major changes, which might require to
12+
update your client code. Make sure to follow the [v7 to v8 Migration Guide](https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md)
13+
in order to streamline the migration process.
1214

13-
[Tech stack](https://github.com/appium/java-client/blob/master/docs/Tech-stack.md)
15+
## Add Appium java client to your test framework
1416

15-
[How to install the project](https://github.com/appium/java-client/blob/master/docs/Installing-the-project.md)
17+
### Stable
1618

17-
[WIKI](https://github.com/appium/java-client/wiki)
19+
#### Maven
1820

19-
## v8 Migration
21+
Add the following to pom.xml:
2022

21-
Since version 8 Appium Java Client had several major changes, which might require to
22-
update your client code. Make sure to follow the [v7 to v8 Migration Guide](https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md)
23-
in order to streamline the migration process.
23+
```xml
24+
<dependency>
25+
<groupId>io.appium</groupId>
26+
<artifactId>java-client</artifactId>
27+
<version>${version.you.require}</version>
28+
<scope>test</scope>
29+
</dependency>
30+
```
31+
32+
#### Gradle
33+
34+
Add the following to build.gradle:
35+
36+
```groovy
37+
dependencies {
38+
testImplementation 'io.appium:java-client:${version.you.require}'
39+
}
40+
```
2441

25-
## How to install latest java client Beta/Snapshots
42+
### Beta/Snapshots
2643

2744
Java client project is available to use even before it is officially published to maven central. Refer [jitpack.io](https://jitpack.io/#appium/java-client)
2845

29-
### Maven
46+
#### Maven
3047

31-
- Add the following to pom.xml:
48+
Add the following to pom.xml:
3249

3350
```xml
3451
<repositories>
@@ -39,7 +56,7 @@ Java client project is available to use even before it is officially published t
3956
</repositories>
4057
```
4158

42-
- Add the dependency:
59+
Add the dependency:
4360

4461
```xml
4562
<dependency>
@@ -49,27 +66,140 @@ Java client project is available to use even before it is officially published t
4966
</dependency>
5067
```
5168

52-
### Gradle
69+
#### Gradle
5370

54-
- Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
71+
Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
5572

56-
```
73+
```groovy
5774
allprojects {
5875
repositories {
59-
...
76+
// ...
6077
maven { url 'https://jitpack.io' }
6178
}
6279
}
6380
```
6481

65-
- Add the dependency:
82+
Add the dependency:
6683

67-
```
84+
```groovy
6885
dependencies {
6986
implementation 'com.github.appium:java-client:latest commit id from master branch'
7087
}
7188
```
7289

90+
## Drivers Support
91+
92+
Appium java client has dedicated classes to support the following Appium drivers:
93+
94+
- [UiAutomator2](https://github.com/appium/appium-uiautomator2-driver) and [Espresso](https://github.com/appium/appium-espresso-driver): [AndroidDriver](src/main/java/io/appium/java_client/android/AndroidDriver.java)
95+
- [XCUITest](https://github.com/appium/appium-xcuitest-driver): [IOSDriver](src/main/java/io/appium/java_client/ios/IOSDriver.java)
96+
- [Windows](https://github.com/appium/appium-windows-driver): [WindowsDriver](src/main/java/io/appium/java_client/windows/WindowsDriver.java)
97+
- [Safari](https://github.com/appium/appium-safari-driver): [SafariDriver](src/main/java/io/appium/java_client/safari/SafariDriver.java)
98+
- [Gecko](https://github.com/appium/appium-geckodriver): [GeckoDriver](src/main/java/io/appium/java_client/gecko/GeckoDriver.java)
99+
- [Mac2](https://github.com/appium/appium-mac2-driver): [Mac2Driver](src/main/java/io/appium/java_client/mac/Mac2Driver.java)
100+
101+
To automate other platforms that are not listed above you could use
102+
[AppiumDriver](src/main/java/io/appium/java_client/AppiumDriver.java) or its custom derivatives.
103+
104+
Appium java client is built on top of Selenium and implements same interfaces that the foundation
105+
[RemoteWebDriver](https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/remote/RemoteWebDriver.java)
106+
does. However, Selenium lib is mostly focused on web browsers automation while
107+
Appium is universal and covers wide range of possible platforms, e.g. mobile and desktop
108+
operating systems, IOT devices, etc. Thus, the foundation `AppiumDriver` class in this package
109+
extends `RemoteWebDriver` with additional features, and makes it more flexible, so it is not so
110+
strictly focused on web-browser related operations.
111+
112+
## Appium Server Service Wrapper
113+
114+
Appium java client provides a dedicated class to control Appium server execution.
115+
The class is [AppiumDriverLocalService](src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java).
116+
It allows to run and verify the Appium server **locally** from your test framework code
117+
and provides several convenient shortcuts. The service could be used as below:
118+
119+
```java
120+
AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
121+
service.start();
122+
try {
123+
// do stuff with drivers
124+
} finally {
125+
service.stop();
126+
}
127+
```
128+
129+
You could customize the service behavior, for example, provide custom
130+
command line arguments or change paths to server executables
131+
using [AppiumServiceBuilder](src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java)
132+
133+
**Note**
134+
135+
> AppiumDriverLocalService does not support the server management on non-local hosts
136+
137+
## Usage Examples
138+
139+
### UiAutomator2
140+
141+
```java
142+
UiAutomator2Options options = new UiAutomator2Options()
143+
.setUdid('123456')
144+
.setApp("/home/myapp.apk");
145+
AndroidDriver driver = new AndroidDriver(
146+
// The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
147+
new URL("http://127.0.0.1:4723"), options
148+
);
149+
try {
150+
WebElement el = driver.findElement(AppiumBy.xpath, "//Button");
151+
el.click();
152+
driver.getPageSource();
153+
} finally {
154+
driver.quit();
155+
}
156+
```
157+
158+
### XCUITest
159+
160+
```java
161+
XCUITestOptions options = new XCUITestOptions()
162+
.setUdid('123456')
163+
.setApp("/home/myapp.ipa");
164+
IOSDriver driver = new IOSDriver(
165+
// The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
166+
new URL("http://127.0.0.1:4723"), options
167+
);
168+
try {
169+
WebElement el = driver.findElement(AppiumBy.accessibilityId, "myId");
170+
el.click();
171+
driver.getPageSource();
172+
} finally {
173+
driver.quit();
174+
}
175+
```
176+
177+
### Any generic driver that does not have a dedicated class
178+
179+
```java
180+
BaseOptions options = new BaseOptions()
181+
.setPlatformName("myplatform")
182+
.setAutomationName("mydriver")
183+
.amend("mycapability1", "capvalue1")
184+
.amend("mycapability2", "capvalue2");
185+
AppiumDriver driver = new AppiumDriver(
186+
// The default URL in Appium 1 is http://127.0.0.1:4723/wd/hub
187+
new URL("http://127.0.0.1:4723"), options
188+
);
189+
try {
190+
WebElement el = driver.findElement(AppiumBy.className, "myClass");
191+
el.click();
192+
driver.getPageSource();
193+
} finally {
194+
driver.quit();
195+
}
196+
```
197+
198+
Check the corresponding driver's READMEs to know the list of capabilities and features it supports.
199+
200+
You could find much more code examples by checking client's
201+
[unit and integration tests](src/test/java/io/appium/java_client).
202+
73203
## Changelog
74204
*8.2.0*
75205
- **[ENHANCEMENTS]**

docs/Functions.md

Lines changed: 0 additions & 147 deletions
This file was deleted.

docs/Page-objects.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ List<IOSElement> someElements;
4646
# The example for the crossplatform mobile native testing
4747

4848
```java
49-
import io.appium.java_client.MobileElement;
5049
import io.appium.java_client.pagefactory.*;
5150

5251
@AndroidFindBy(someStrategy)
5352
@iOSFindBy(someStrategy)
54-
MobileElement someElement;
53+
WebElement someElement;
5554

5655
@AndroidFindBy(someStrategy) //for the crossplatform mobile native
5756
@iOSFindBy(someStrategy) //testing
58-
List<MobileElement> someElements;
57+
List<WebElement> someElements;
5958
```
6059

6160
# The fully cross platform example

0 commit comments

Comments
 (0)