I am trying to upload file by adding
driver.findElementsByXpath("").sendkeys("filepath");
but that is not working.
I am trying to upload file by adding
driver.findElementsByXpath("").sendkeys("filepath");
but that is not working.
There is no way to repeat that trick from web in native mobile app: simply because it doesn't work that easy here.
You have to do it step by step, e.g. click button to open gallery, find image in gallery and click it, etc.
On the other hand, there is a push_file
end point in Appium to put file on device: https://appium.readthedocs.io/en/latest/en/commands/device/files/push-file/
There is a nice blog post with code sample available here:
File assetDir = new File(classpathRoot, "../assets");
File img = new File(assetDir.getCanonicalPath(), "cloudgrey.png");
driver.pushFile(ANDROID_PHOTO_PATH + "/" + img.getName(), img);
// navigate to photo selection in your app, open gallery and click the recently uploaded image