Skip to main content

Push files to device

For Android devices​

Preconditions

On Android, you can push files to these folders:

  • /sdcard/Download/
  • /sdcard/Pictures
  • /sdcard/Android/data/<app_package>

Follow these steps:

  1. In Katalon Studio, click the Profile drop-down and select Reload Plugins to make sure the plugin is installed.

    Reload plugins
  2. Add the FileExecutor.pushFiletoDevice keyword to your test case.

    1. In Manual view: Click (+) Add Custom Keyword and select com.katalon.testcloud.FileExecutor.pushFiletoDevice. In the Input field, provide the values for destinationPath and localFilePath.

    Add network throttling keyword to test case
    1. In Script view, the keyword is added as follows:
    CustomKeywords.'com.katalon.testcloud.FileExecutor.pushFiletoDevice'("/sdcard/Pictures/puppy.png", "/Users/demouser/Pictures/puppy.png") 

Example code

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling

'Push file to the device'
String localPath = '/Users/demouser/Pictures/puppy.png'
CustomKeywords.'com.katalon.testcloud.FileExecutor.pushFileToDevice'('/sdcard/Pictures/puppy.png', localPath)

'Login to the app'
Mobile.setText(findTestObject('Object Repository/Native App/MyDemoApp/android.widget.EditText - Username'), 'mydemouser', 0)
Mobile.setEncryptedText(findTestObject('Object Repository/Native App/MyDemoApp/android.widget.EditText - Password'), 'tTkSizDjdvtHYxURT8SvuQ==', 0)
Mobile.hideKeyboard(FailureHandling.OPTIONAL)
Mobile.tap(findTestObject('Object Repository/Native App/MyDemoApp/android.widget.Button - Login'), 0)

'Open the Gallery'
Mobile.tap(findTestObject('Object Repository/Native App/MyDemoApp/android.widget.Button - Camera'), 0)
Mobile.tap(findTestObject('Object Repository/Native App/MyDemoApp/android.widget.Button - Open Gallery'), 0)

'Take screenshot to verify the file is pushed to the device'
Mobile.takeScreenshot(FailureHandling.CONTINUE_ON_FAILURE)
  1. Configure your TestCloud mobile environment and run the test.

Workaround for iOS devices​

The pushFileToDevice keyword is not officially supported for iOS devices. To perform this action, apply the following workaround using Appium's pushFile function.

Preconditions
  • The target app must enable file sharing by setting UIFileSharingEnabled=true in Info.plist.
  • The test must obtain an active mobile driver instance (e.g., via Mobile.startApplication and MobileDriverFactory).
  1. Specify the destination inside the app sandbox using this format @<app_bundle_id>:Documents/<file_name>.

  2. Provide a java.io.File pointing to a resolved absolute/local path for the file to push.

  3. Use the pushFile function in Appium with the destination path and the source File object.

note
  • This workaround supports major iOS versions (for example, iOS 26 instead of 26.1).
  • Ensure device/app permissions and sandboxing allow writing to the Documents directory.

Example:

import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
Mobile.startApplication('24fa5a50-8d7d-42b3-9dec-aea3b1ab35bb', false)
String localPath = new File(RunConfiguration.getProjectDir() + '/' + 'Data Files/puppy.png').getCanonicalPath()
MobileDriverFactory.getDriver().pushFile("@com.test.ios.mydemoapp:Documents/puppy.png", new File(localPath));
Was this page helpful?