Add pushFile support to IOSDriver by mykola-mokhnach · Pull Request #721 · appium/java-client · GitHub
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
15 changes: 15 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,6 @@ public class AndroidMobileCommandHelper extends MobileCommand {
OPEN_NOTIFICATIONS, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* file pushing
*
* @param remotePath Path to file to write data to on remote device
* @param base64Data Base64 encoded byte array of data to write to remote device
* @return a key-value pair. The key is the command name. The value is a
* {@link java.util.Map} command arguments.
*/
public static Map.Entry<String, Map<String, ?>> pushFileCommandCommand(String remotePath,
byte[] base64Data) {
String[] parameters = new String[] {"path", "data"};
Object[] values = new Object[] {remotePath, base64Data};
return new AbstractMap.SimpleEntry<>(PUSH_FILE, prepareArguments(parameters, values));
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* setting of device network connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.appium.java_client.android;

import static com.google.common.base.Preconditions.checkNotNull;
import static io.appium.java_client.android.AndroidMobileCommandHelper.pushFileCommandCommand;
import static io.appium.java_client.MobileCommand.pushFileCommand;

import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.ExecutesMethod;
Expand All @@ -37,7 +37,7 @@ public interface PushesFiles extends InteractsWithFiles, ExecutesMethod {
* @param base64Data Base64 encoded byte array of data to write to remote device
*/
default void pushFile(String remotePath, byte[] base64Data) {
CommandExecutionHelper.execute(this, pushFileCommandCommand(remotePath, base64Data));
CommandExecutionHelper.execute(this, pushFileCommand(remotePath, base64Data));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/appium/java_client/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class IOSDriver<T extends WebElement>
extends AppiumDriver<T>
implements HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings,
FindsByIosUIAutomation<T>, LocksIOSDevice, PerformsTouchID, FindsByIosNSPredicate<T>,
FindsByIosClassChain<T> {
FindsByIosClassChain<T>, PushesFiles {

private static final String IOS_PLATFORM = MobilePlatform.IOS;

Expand Down
64 changes: 64 additions & 0 deletions src/main/java/io/appium/java_client/ios/PushesFiles.java