Edit this Doc Pushing/Pulling files

Appium provides Pull Folder, Pull File and Push File to move files. This documentation aims to help to understand how they work for iOS.

Format

Below is the basic format.

  1. @<app_bundle_id>:<optional_container_type>/<path_to_the_file_or_folder_inside_container>
  2. @<app_bundle_id>/<path_to_the_file_or_folder_inside_container>
  3. <path_to_the_file_or_folder_inside_container>

Real device

Format

The format of method argument should be the following:

format 3 is not allowed for real devices.

Example

If you would like to pull Presentation.key form Keynote app, you can get it as below.

let data = driver.pullFile('@io.appium.example:documents/Presentation.key');
await fs.writeFile('presentation.key', Buffer.from(data, 'base64'), 'binary');
file = @driver.pull_file '@com.apple.Keynote:documents/Presentation.key'
File.open('presentation.key', 'wb') { |f| f<< file }

The file is in On My iPhone/Keynote of Files app.

Top On My iPhone Keynote

If the file is in deeper place like On My iPhone/Keynote/Dir1/Dir2, then the Ruby command should be:

let data = driver.pullFile('@io.appium.example:documents/Dir1/Dir2/Presentation.key');
await fs.writeFile('presentation.key', Buffer.from(data, 'base64'), 'binary');
file = @driver.pull_file '@com.apple.Keynote:documents/Dir1/Dir2/Presentation.key'
File.open('presentation.key', 'wb') { |f| f<< file }

You can pull documents root of On My iPhone/Keynote as @driver.pull_folder '@com.apple.Keynote:documents/'.

let data = driver.pullFolder('@io.appium.example:documents/');
await fs.writeFile('documents.zip', Buffer.from(data, 'base64'), 'binary');
file = @driver.pull_folder '@com.apple.Keynote:documents/'
File.open('documents.zip', 'wb') { |f| f<< file }

Same as pull:

driver.pushFile('@com.apple.Keynote:documents/text.txt', new Buffer("Hello World").toString('base64'));
@driver.push_file '@com.apple.Keynote:documents/text.txt', (File.read 'path/to/file')

Simulator

Format

The format of method argument should be the following:

format 3 format handles as app container

Example

// Java
// Get AddressBook.sqlitedb in test app package ('app' container)
byte[] fileContent = driver.pullFile("Library/AddressBook/AddressBook.sqlitedb");
Path dstPath = Paths.get(new File("/local/path/AddressBook.sqlitedb"));
Files.write(dstPath, fileContent);

references