Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing of Android Application without resetting its state using Appium and Selenium WebDriver

I wish to test my android application without resetting its state. I noticed that different popups appear everytime I run the application so I wish to log all the various popups.

My definition of "run" here is tapping the back button on my phone and tapping my application icon again.

However, I am unable to simulate this physical tapping of the phone on my Appium test. I can exit my first test but I am unable to reopen my application again. (Simulation of tapping on the application icon with my finger)

Things I have tried:

1. Setting noReset to true in capabilities setting

2. Using uiautomator to find my application.  However, uiautomator doesn't seem to be able to detect any icons in the app menu page. It just shows many layers of frame layouts.

3. closeApp() and launchApp() resets the application and this defeats the purpose of my test.  My application somehow behaves differently with each run so I hope to run my test in a single session (i.e. closing and opening the application while it is still in the same state)

Is there anyway I can simulate the physical tapping of the icon in the form of code? I know we can set the coordinates but I don't want to hard code my test to run only on a specific instance of the phone. It will not run if other applications are uninstalled and my application icon shifts to another position.

like image 761
ykw Avatar asked Oct 13 '25 06:10

ykw


1 Answers

This worked for me:

"appPackage": "com.company.app",
"appActivity": "com.company.app.activities.HomeActivity",
"skipDeviceInitialization": true,
"skipServerInstallation": true,
"noReset": true

This won't reinstall the .apk, appium server and it won't delete the appdata. You can just start the app like you've left it before starting the test.

I found this browsing the same issues on GitHub:

https://github.com/appium/appium/issues/4955

https://github.com/appium/appium/issues/3783

like image 185
Lawrence Avatar answered Oct 14 '25 20:10

Lawrence