Appium provides Pull Folder, Pull File and Push File to move files. This documentation aims to help to understand how they work for iOS.
Below is the basic format.
@<app_bundle_id>:<optional_container_type>/<path_to_the_file_or_folder_inside_container>
@<app_bundle_id>/<path_to_the_file_or_folder_inside_container>
<path_to_the_file_or_folder_inside_container>
The format of method argument should be the following:
@<app_bundle_id>
is the application bundle identifieroptional_container_type
is the container typedocuments
is the only available option- The others work as format 2
- Only apps having the flag
UIFileSharingEnabled
in theirinfo.plist
can be mounted
- Only apps having the flag
path_to_the_file_or_folder_inside_container
is the target to push/pull to/from them.- If the
optional_container_type
isdocuments
, this path will be mapped toOn My iPhone/<app name>
in Files app
- If the
format 3 is not allowed for real devices.
If you would like to pull Presentation.key form Keynote app, you can get it as below.
- Pull file
// webdriver.io
let data = driver.pullFile('@io.appium.example:documents/Presentation.key');
await fs.writeFile('presentation.key', Buffer.from(data, 'base64'), 'binary');
# ruby_lib_core
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:
// webdriver.io
let data = driver.pullFile('@io.appium.example:documents/Dir1/Dir2/Presentation.key');
await fs.writeFile('presentation.key', Buffer.from(data, 'base64'), 'binary');
# ruby_lib_core
file = @driver.pull_file '@com.apple.Keynote:documents/Dir1/Dir2/Presentation.key'
File.open('presentation.key', 'wb') { |f| f<< file }
- Pull folder
You can pull documents root of On My iPhone/Keynote as @driver.pull_folder '@com.apple.Keynote:documents/'
.
// webdriver.io
let data = driver.pullFolder('@io.appium.example:documents/');
await fs.writeFile('documents.zip', Buffer.from(data, 'base64'), 'binary');
# ruby_lib_core
file = @driver.pull_folder '@com.apple.Keynote:documents/'
File.open('documents.zip', 'wb') { |f| f<< file }
- Push file
Same as pull:
// webdriver.io
driver.pushFile('@com.apple.Keynote:documents/text.txt', new Buffer("Hello World").toString('base64'));
# ruby_lib_core
@driver.push_file '@com.apple.Keynote:documents/text.txt', (File.read 'path/to/file')
The format of method argument should be the following:
@<app_bundle_id>
is the application bundle identifieroptional_container_type
is the container typeapp
,data
,groups
or<A specific App Group container>
- format 2 case is handled as
app
container
path_to_the_file_or_folder_inside_container
is the target to push/pull to/from them
format 3 format handles as app
container
// 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);
- https://stackoverflow.com/questions/1108076/where-does-the-iphone-simulator-store-its-data
- https://stackoverflow.com/questions/48884248/how-can-i-add-files-to-the-ios-simulator
- https://apple.stackexchange.com/questions/299413/how-to-allow-the-files-app-to-save-to-on-my-iphone-or-to-on-my-ipad-in-ios/299565#299565