Push files to device
To upload files to a TestCloud device, you can use the pushFiletoDevice
keyword.
- This keyword is applicable for Android devices only.
- You have installed the Katalon TestCloud Keywords plugin from Katalon Store. If you have not, visit: Katalon TestCloud Keywords.
On Android, you can push files to these folders:
/sdcard/Download/
/sdcard/Pictures
/sdcard/Android/data/<app_package>
Follow these steps:
-
In Katalon Studio, click the Profile drop-down and select Reload Plugins to make sure the plugin is installed.
-
Add the
FileExecutor.pushFiletoDevice
keyword to your test case.- In Manual view: Click (+) Add Custom Keyword and select
com.katalon.testcloud.FileExecutor.pushFiletoDevice
. In the Input field, provide the values fordestinationPath
andlocalFilePath
.
- In Script view, the keyword is added as follows:
CustomKeywords.'com.katalon.testcloud.FileExecutor.pushFiletoDevice'("/sdcard/Pictures/puppy.png", "/Users/demouser/Pictures/puppy.png")
- In Manual view: Click (+) Add Custom Keyword and select
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)
- Configure your TestCloud mobile environment and run the test.