- To push a file to remote Virtual and Real mobile devices, pushFile function driver.pushFile("FilepathToRemoteDevice", new File("FilePathFromLocal")) of Appium gets used.
- We only support this feature on Emulators/Simulator and Android Real devices, but it's not supported on iOS Real devices.
- Additionally, unlike LocalFileDetector, pushFile function only pushes the file to the device and does not allow the same sendKeys functionality where we can simply send the file's path to the input element. Therefore all the actions like clicking on Choose file-> Photo library -> All Photos-> Selecting the photo etc. has to be done by native mobile elements.
Path on the remote device where the file being pushed
- The complete path is not needed for iOS simulators/Real iOS devices, just give any name to the file with file extension e.g. SamplePicture.jpg, Picture.png, etc. and the photo will be pushed into the photos/gallery.
driver.pushFile("Naruto.png", new File("LocalFilePath"))
- In the case of Android, we need to give the complete path in the function. (Check the GitHub sample project under documentation section)
Path of the File from the local machine
- We need to pass the Base64 string of the local file path in the pushFile function, site https://www.base64-image.de/ can be used to generate Base64 string for smaller files.
The reason it is not supported on iOS Real devices
- Appium does not support this for versions 1.15 and higher.
- Before Appium version 1.15, the Xcuitest driver was using ifuse to access files on real devices. Since v 1.15 we deprecated this component and implemented the functionality using appium-ios-device lib, which is using lockdown communication protocol to do the exchange.
- If you try this with Appium 1.14.0 on Sauce Labs, this version needs ifuse to use this functionality and as this is long deprecated, we get an error "not found: ifuse"
- SauceLabs does not support pushing files for iOS real devices for Appium 1.15.0 and lower because ifuse is deprecated
- Appium does not support it on iOS real devices for Appium versions above 1.15.0 because of an iOS limitation