Help needed for uploading an attachment in mobile device using appium

Can someone help me in understanding how to upload a file in mobile application on real android device using appium. We are automating mobile web application so tried using sendkeys(path) method on the input tag and the path is like “phone/resources/myfile.pdf” where resources is the folder i created in internal phone storage but this is of no help. Is it the right way to do ?

Kindly can someone help.
Thanks in advance

Yes this path is wrong actually. To get exact path you can use below step by step adb commands

 1.  adb shell – Get shell on target device
 2.  ls –l | grep “storage” – List files/directories with name storage 
 3. cd storage – Changed current directory to ‘storage’
 4. ls –l | grep “sdcard” – List files/directories with name sdcard
 5. pwd – See current path, this is remote path from where u r actually uploading myfile.pdf
1 Like

Thanks @amitjaincoer191… Your answer is very helpful :grinning:

You can check if you have secondary external storage with this command:

echo $SECONDARY_STORAGE

Alternately, you should be able to find a writable location in /sdcard. Both of these commands assum you are starting in an adb shell

@willosser
can we use the above method to upload image from deivice gallery to the native app… or any other way…

Thanks

@hariumesh I’m not certain what hooks you have to upload images into your app. A while back, we used broadcast an intent to inform gallery that it needed to rescan the images file. Perhaps something similar will work for you.

@amitjaincoer191 When i am doing the same it is showing error as "Permission Denied"

so how to mitigate this issue please share !!

@sameer.sehgal at which command it is showing Permission Denied