Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 13 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,17 @@

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)

[How to install it and to use it](https://github.com/appium/java-client/blob/master/docs/Installing-the-project.md)

[API docs](http://appium.github.io/java-client/)

###Structure###

There is an abstract `io.appium.java_client.AppiumDriver` class which extends `org.openqa.selenium.remote.RemoteWebDriver`
from the Selenium Java Client. The `io.appium.java_client.AppiumDriver` class contains all methods shared by iOS and Android.
`io.appium.java_client.ios.IOSDriver` and `io.appium.java_client.android.AndroidDriver` both extend `io.appium.java_client.AppiumDriver`
and provide more methods, and specific implementations for some methods.

In the same way, `io.appium.java_client.ios.IOSElement` and `io.appium.java_client.android.AndroidElement` both are subclasses of
`io.appium.java_client.MobileElement`


###Added functions###
More can be found in the docs, but here's a quick list of features which this project has added to the usual selenium binding.


- startActivity()
- resetApp()
- getAppStringMap()
- pressKeyCode()
- longPressKeyCode()
- longPressKey()
- currentActivity()
- getDeviceTime()
- pullFile()
- pushFile()
- pullFolder()
- replaceValue()
- hideKeyboard()
- runAppInBackground()
- performTouchAction()
- performMultiTouchAction()
- tap()
- swipe()
- pinch()
- zoom()
- isAppInstalled()
- installApp()
- removeApp()
- launchApp()
- closeApp()
- endTestCoverage()
- isLocked()
- shake()
- getSessionDetails()
- openNotifications()
- Context Switching: .context(), .getContextHandles(), getContext())
- setConnection(), getConnection()
- ignoreUnimportantViews(), getSettings()
- toggleLocationServices()
- lockDevice()
- unlockDevice()

Locators:
- findElementByAccessibilityId()
- findElementsByAccessibilityId()
- findElementByIosUIAutomation()
- findElementsByIosUIAutomation()
- findElementByAndroidUIAutomator()
- findElementsByAndroidUIAutomator()

### Features and other interesting information###

You can get it on [WIKI](https://github.com/appium/java-client/wiki)

## Changelog#
###Features and other interesting information###

[Tech stack](https://github.com/appium/java-client/blob/master/docs/Tech-stack.md)

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

[WIKI](https://github.com/appium/java-client/wiki)

##Changelog##
*5.0.0 (under construction yet)*
- **[MAJOR ENHANCEMENT]**: Migration to Java 8. Epic: [#399](https://github.com/appium/java-client/issues/399)
- API with default implementation. PR [#470](https://github.com/appium/java-client/pull/470)
Expand Down Expand Up @@ -156,7 +98,6 @@ You can get it on [WIKI](https://github.com/appium/java-client/wiki)

- [ENHANCEMENT] Added the ability to set UiAutomator Congfigurator values. [#410](https://github.com/appium/java-client/pull/410).
[#477](https://github.com/appium/java-client/pull/477).
- **[UPDATE]** to Selenium 3.0. [#489](https://github.com/appium/java-client/pull/489)
- [ENHANCEMENT]. Additional methods which perform device rotation were implemented. [#489](https://github.com/appium/java-client/pull/489). [#439](https://github.com/appium/java-client/pull/439). But it works for iOS in XCUIT mode and for Android in UIAutomator2 mode only. The feature request: [#7131](https://github.com/appium/appium/issues/7131)
- [ENHANCEMENT]. TouchID Implementation (iOS Sim Only). Details: [#509](https://github.com/appium/java-client/pull/509)
- [ENHANCEMENT]. The ability to use port, ip and log file as server arguments was provided. Feature request: [#521](https://github.com/appium/java-client/issues/521). Fixes: [#522](https://github.com/appium/java-client/issues/522), [#524](https://github.com/appium/java-client/issues/524).
Expand All @@ -183,6 +124,10 @@ You can get it on [WIKI](https://github.com/appium/java-client/wiki)
- `IOSMobileCapabilityType#WEB_DRIVER_AGENT_URL`
- `IOSMobileCapabilityType#KEYCHAIN_PATH`
- `MobileCapabilityType#CLEAR_SYSTEM_FILES`
- **[UPDATE]** to Selenium 3.0.1.
- **[UPDATE]** to Spring Framework 4.3.5.RELEASE.
- **[UPDATE]** to AspectJ weaver 1.8.10.



*4.1.2*
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'checkstyle'
apply plugin: 'signing'

group 'io.appium'
version '5.0.0-SNAPSHOT'
version '5.0.0-BETA1'

repositories {
jcenter()
Expand Down Expand Up @@ -50,19 +50,19 @@ compileJava {
}

dependencies {
compile('org.seleniumhq.selenium:selenium-java:3.0.0'){
compile('org.seleniumhq.selenium:selenium-java:3.0.1'){
exclude module: 'cglib'
exclude group: 'com.google.code.gson'
}
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'com.google.guava:guava:19.0'
compile 'com.google.guava:guava:20.0'
compile 'cglib:cglib:3.2.4'
compile 'commons-validator:commons-validator:1.5.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.apache.commons:commons-lang3:3.5'
compile 'commons-io:commons-io:2.5'
compile 'org.springframework:spring-context:4.3.2.RELEASE'
compile 'org.aspectj:aspectjweaver:1.8.9'
compile 'org.springframework:spring-context:4.3.5.RELEASE'
compile 'org.aspectj:aspectjweaver:1.8.10'

testCompile 'junit:junit:4.12'
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/appium/java_client/PerformsActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.appium.java_client;

public interface PerformsActions<T extends PerformsActions> {
public interface PerformsActions<T extends PerformsActions<T>> {

T perform();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public final class AppiumDriverLocalService extends DriverService {
private final TimeUnit timeUnit;
private final ReentrantLock lock = new ReentrantLock(true); //uses "fair" thread ordering policy
private final ListOutputStream stream = new ListOutputStream().add(System.out);
private final URL url;



Expand All @@ -64,6 +65,7 @@ public final class AppiumDriverLocalService extends DriverService {
this.nodeJSEnvironment = nodeJSEnvironment;
this.startupTimeout = startupTimeout;
this.timeUnit = timeUnit;
this.url = new URL(String.format(URL_MASK, this.ipAddress, this.nodeJSPort));
}

public static AppiumDriverLocalService buildDefaultService() {
Expand All @@ -78,11 +80,7 @@ public static AppiumDriverLocalService buildService(AppiumServiceBuilder builder
* @return The base URL for the managed appium server.
*/
@Override public URL getUrl() {
try {
return new URL(String.format(URL_MASK, ipAddress, nodeJSPort));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return url;
}

@Override public boolean isRunning() {
Expand All @@ -101,22 +99,18 @@ public static AppiumDriverLocalService buildService(AppiumServiceBuilder builder
return true;
} catch (UrlChecker.TimeoutException e) {
return false;
} catch (MalformedURLException e) {
throw new AppiumServerHasNotBeenStartedLocallyException(e.getMessage(), e);
}
} finally {
lock.unlock();
}

}

private void ping(long time, TimeUnit timeUnit) throws UrlChecker.TimeoutException {
URL url = getUrl();
try {
URL status = new URL(url.toString() + "/status");
new UrlChecker().waitUntilAvailable(time, timeUnit, status);
} catch (MalformedURLException e) {
throw new RuntimeException(
"There is something wrong with the URL " + url.toString().toString() + "/status");
}
private void ping(long time, TimeUnit timeUnit) throws UrlChecker.TimeoutException, MalformedURLException {
URL status = new URL(url.toString() + "/status");
new UrlChecker().waitUntilAvailable(time, timeUnit, status);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
import static org.junit.Assert.assertTrue;

import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;
import org.junit.Test;

public class ThreadSafetyTest {

private final AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
private final Action run = new Action() {
@Override Object perform() {
@Override protected Object perform() {
service.start();
return "OK";
}
};
private final Action run2 = run.clone();
private final Action isRunning = new Action() {
@Override Object perform() {
@Override protected Object perform() {
return service.isRunning();
}
};
private final Action isRunning2 = isRunning.clone();
private final Action stop = new Action() {
@Override Object perform() {
@Override protected Object perform() {
service.stop();
return "OK";
}
Expand Down Expand Up @@ -198,13 +199,13 @@ public class ThreadSafetyTest {


private abstract static class Action implements Cloneable {
abstract Object perform();
protected abstract Object perform();

public Action clone() {
try {
return (Action) super.clone();
} catch (Throwable t) {
throw new RuntimeException(t);
throw new AppiumServerHasNotBeenStartedLocallyException(t.getMessage(), t);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static class MockWebDriver implements WebDriver {

@Override
public void get(String url) {

System.out.print(url);
}

@Override
Expand Down Expand Up @@ -58,12 +58,12 @@ public String getPageSource() {

@Override
public void close() {

System.out.print("Closed");
}

@Override
public void quit() {

System.out.print("Died");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public class SelendroidModeTest {

@Test public void findBySelendroidLinkTextTest() {
assertEquals("Accessibility", textLink.getText());
}

@Test public void findBySelendroidPartialLinkTextTest() {
assertEquals("Accessibility", textPartialLink.getText());
}
}