ykw
ykw

Reputation: 101

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.

Upvotes: 4

Views: 6489

Answers (3)

Lawrence
Lawrence

Reputation: 61

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

Upvotes: 6

krishna chetan
krishna chetan

Reputation: 659

You can start the app by giving The package name and start activity name instead of apk file in desired caps , this way ur app won't be reset every time u launch app Den use presskey4 for tapping in back button , den u can call launch app function to launch the app without reset

Upvotes: 0

Naman
Naman

Reputation: 31878

If I am not getting you wrong here, you can try using a combination of following using AndroidDriver :

driver.navigate().back(); // from app home screen to mobile home screen
driver.startActivity(String appPackage, String appActivity); // or possibly cast ((AndroidDriver)driver)

Upvotes: 0

Related Questions