How to use pushFileCommand method of io.appium.java_client.MobileCommand class

Best io.appium code snippet using io.appium.java_client.MobileCommand.pushFileCommand

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Source: Github

2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
19import static;
20import static io.appium.java_client.MobileCommand.pushFileCommand;
22import io.appium.java_client.CommandExecutionHelper;
23import io.appium.java_client.ExecutesMethod;
24import io.appium.java_client.InteractsWithFiles;
25import org.apache.commons.codec.binary.Base64;
31public interface PushesFiles extends InteractsWithFiles, ExecutesMethod {
33    /**
34     * Saves base64 encoded data as a file on the remote mobile device.
35     *
36     * @param remotePath Path to file to write data to on remote device
37     * @param base64Data Base64 encoded byte array of data to write to remote device
38     */
39    default void pushFile(String remotePath, byte[] base64Data) {
40        CommandExecutionHelper.execute(this, pushFileCommand(remotePath, base64Data));
41    }
43    /**
44     * Saves given file as a file on the remote mobile device.
45     *
46     * @param remotePath Path to file to write data to on remote device
47     * @param file is a file to write to remote device
48     * @throws IOException when there are problems with a file or current file system
49     */
50    default void pushFile(String remotePath, File file) throws IOException {
51        checkNotNull(file, "A reference to file should not be NULL");
52        if (!file.exists()) {
53            throw new IOException("The given file "
54                + file.getAbsolutePath() + " doesn't exist");
55        }
56        pushFile(remotePath,
57            Base64.encodeBase64(FileUtils.readFileToByteArray(file)));
58    }
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger pushFileCommand code on LambdaTest Cloud Grid

Execute automation tests with pushFileCommand on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)