Skip to main content

Failed to upload files for native mobile application

The test fails to upload files in mobile devices provided by TestCloud.

The workaround is to use the pushFile function with the code below so that the file can be uploaded automatically to the test devices.
On Android, you can push files to these folders:
  • /sdcard/Download/
  • /sdcard/Pictures
  • /sdcard/Android/data/<app_package>
driver.pushFile("/sdcard/Download/sample.jpg", new File("/Users/katalonuser/Desktop/sample.png"));
On iOS, you can push files to the document folder. Make sure that the app has UIFileSharingEnabled key set to true in the Info.plist.
driver.pushFile("@<app_bundle_id>:documents/sample.png", new File("/Users/katalonuser/Desktop/sample.png"));
Sample code:
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver

String localPath = new File(RunConfiguration.getProjectDir() + '/' + 'Data Files/puppy.png').getCanonicalPath()
String filePath = localPath
AppiumDriver<?> driver = MobileDriverFactory.getDriver()

if (driver.class == com.kms.katalon.core.appium.driver.SwipeableAndroidDriver) {
filePath = '/sdcard/Pictures/puppy.png'
driver.pushFile(filePath, new File(localPath))
} else if (driver.class == io.appium.java_client.ios.IOSDriver) {
filePath = '@com.imgur.mobile:documents/puppy.png'
driver.pushFile(filePath, new File(localPath))
}