Skip to content
Closed
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
1,382 changes: 630 additions & 752 deletions src/main/java/io/appium/java_client/AppiumDriver.java

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/main/java/io/appium/java_client/DeviceActionShortcuts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.appium.java_client;

public interface DeviceActionShortcuts {

/**
* Hides the keyboard if it is showing.
* On iOS, there are multiple strategies for hiding the keyboard. Defaults to the "tapOutside" strategy (taps outside the keyboard).
* Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work.
*/
public void hideKeyboard();

/**
* Send a key event to the device
*
* @param key code for the key pressed on the device
*
* @see AndroidKeyCode
* @see IOSKeyCode
*/
public void sendKeyEvent(int key);

}
2 changes: 1 addition & 1 deletion src/main/java/io/appium/java_client/IOSKeyCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package io.appium.java_client;

/**
* Some common key codes for Android Key Events
* Some common key codes for iOS Key Events
*/
public interface IOSKeyCode {

Expand Down
54 changes: 54 additions & 0 deletions src/main/java/io/appium/java_client/InteractsWithApps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.appium.java_client;

public interface InteractsWithApps {
/**
* Launch the app which was provided in the capabilities at session creation
*/
public void launchApp();

/**
* Install an app on the mobile device
*
* @param appPath
* path to app to install
*/
public void installApp(String appPath);

/**
* Checks if an app is installed on the device
*
* @param bundleId
* bundleId of the app
* @return True if app is installed, false otherwise
*/
public boolean isAppInstalled(String bundleId);

/**
* Reset the currently running app for this session
*/
public void resetApp();

/**
* Runs the current app as a background app for the number of seconds
* requested. This is a synchronous method, it returns after the back has
* been returned to the foreground.
*
* @param seconds
* Number of seconds to run App in background
*/
public void runAppInBackground(int seconds);

/**
* Remove the specified app from the device (uninstall)
*
* @param bundleId
* the bunble identifier (or app id) of the app to remove
*/
public void removeApp(String bundleId);

/**
* Close the app which was provided in the capabilities at session creation
*/
public void closeApp();

}
30 changes: 30 additions & 0 deletions src/main/java/io/appium/java_client/InteractsWithFiles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.appium.java_client;

public interface InteractsWithFiles {

/**
*
* @param remotePath
* On Android and iOS, this is either the path to the file
* (relative to the root of the app's file system). On iOS only,
* if path starts with /AppName.app, which will be replaced with
* the application's .app directory
* @return A byte array of Base64 encoded data.
*/
public byte[] pullFile(String remotePath);

/**
* Pull a folder from the simulator/device. Does not work on iOS Real
* Devices, but works on simulators
*
* @param remotePath
* On Android and iOS, this is either the path to the file
* (relative to the root of the app's file system). On iOS only,
* if path starts with /AppName.app, which will be replaced with
* the application's .app directory
* @return A byte array of Base64 encoded data, representing a ZIP ARCHIVE
* of the contents of the requested folder.
*/
public byte[] pullFolder(String remotePath);

}
12 changes: 3 additions & 9 deletions src/main/java/io/appium/java_client/MobileDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@

package io.appium.java_client;


import org.openqa.selenium.ContextAware;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.Response;

import java.util.Map;

public interface MobileDriver extends WebDriver, ContextAware {


public Response execute(String driverCommand, Map<String, ?> parameters);

public TouchAction performTouchAction(TouchAction touchAction);

public void performMultiTouchAction(MultiTouchAction multiAction);
public interface MobileDriver extends WebDriver, ContextAware,
PerformsTouchActions {
public Response execute(String driverCommand, Map<String, ?> parameters);
}
31 changes: 31 additions & 0 deletions src/main/java/io/appium/java_client/PerformsTouchActions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.appium.java_client;

public interface PerformsTouchActions {
/**
* Performs a chain of touch actions, which together can be considered an
* entire gesture. See the Webriver 3 spec
* https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html
*
* It's more convenient to call the perform() method of the TouchAction
* object itself.
*
* @param touchAction
* A TouchAction object, which contains a list of individual
* touch actions to perform
* @return the same touch action object
*/
public TouchAction performTouchAction(TouchAction touchAction);

/**
* Performs multiple TouchAction gestures at the same time, to simulate
* multiple fingers/touch inputs. See the Webriver 3 spec
* https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html
*
* It's more convenient to call the perform() method of the MultiTouchAction
* object.
*
* @param multiAction
* the MultiTouchAction object to perform.
*/
public void performMultiTouchAction(MultiTouchAction multiAction);
}
9 changes: 9 additions & 0 deletions src/main/java/io/appium/java_client/ScrollsTo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.appium.java_client;

public interface ScrollsTo {

public MobileElement scrollTo(String text);

public MobileElement scrollToExact(String text);

}
99 changes: 99 additions & 0 deletions src/main/java/io/appium/java_client/TouchShortcuts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package io.appium.java_client;

import org.openqa.selenium.WebElement;

public interface TouchShortcuts {

/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen to place one of them
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param x x coordinate to start zoom on
* @param y y coordinate to start zoom on
*/
public void zoom(int x, int y);

/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen to place one of them
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param el The element to pinch
*/
public void zoom(WebElement el);

/**
* Convenience method for tapping a position on the screen
*
* @param fingers
* number of fingers/appendages to tap with
* @param x
* x coordinate
* @param y
* y coordinate
* @param duration
*/
public void tap(int fingers, int x, int y, int duration);

/**
* Convenience method for tapping the center of an element on the screen
*
* @param fingers
* number of fingers/appendages to tap with
* @param element
* element to tap
* @param duration
* how long between pressing down, and lifting fingers/appendages
*/
public void tap(int fingers, WebElement element, int duration);

/**
* Convenience method for swiping across the screen
*
* @param startx
* starting x coordinate
* @param starty
* starting y coordinate
* @param endx
* ending x coordinate
* @param endy
* ending y coordinate
* @param duration
* amount of time in milliseconds for the entire swipe action to
* take
*/
public void swipe(int startx, int starty, int endx, int endy, int duration);

/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element at a distance, if this would happen to place
* one of them off the screen, appium will return an outOfBounds error. In this case, revert to using the
* MultiTouchAction api instead of this method.
*
* @param x x coordinate to terminate the pinch on
* @param y y coordinate to terminate the pinch on
*/
public void pinch(int x, int y);

/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element, if this would happen to place one of them
* off the screen, appium with return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param el The element to pinch
*/
public void pinch(WebElement el);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.appium.java_client.android;

import io.appium.java_client.AndroidKeyCode;
import io.appium.java_client.DeviceActionShortcuts;

public interface AndroidDeviceActionShortcuts extends DeviceActionShortcuts {
/**
* Send a key event along with an Android metastate to an Android device
* Metastates are things like *shift* to get uppercase characters
*
* @param key code for the key pressed on the Android device
* @param metastate metastate for the keypress
*
* @see AndroidKeyCode
* @see AndroidKeyMetastate
*/
public void sendKeyEvent(int key, Integer metastate);
}
Loading