Hello there,
I’ve got an issue while testing an Android application which requires the user to select a certificate on app startup.
My setup:
- Platform: Android
- Appium 1.4.16
- Android Emulator API 19
- Java-Client 3.3.0
- Mac OS X 10.10.5 Yosemite
Appium is able to launch the application using the capabilities appPackage=com.company.app and appActivity=.CertificateCheckActivity.
Because I had to set a lock screen PIN for the credential storage, Appium uses the Unlock.apk to give my app the main focus (the device says locked nonetheless).
However, when the emulator is started Android asks then for that PIN (that is com.android.settings.CredentialStorage).
If I don’t specify anything in appWaitPackage and appWaitActivity, Appium aborts the session creation, giving me an error that my application com.company.app.CertificateCheckActivity was never started.
If I specify appWaitPackage=com.android.settings and appWaitActivity=.CredentialStorage Appium creates the session and I can enter and submit the PIN (in the JUnit-setUp method), enabling the credential storage.
Now my app asks for the certificate and for that, Android displays com.android.keychain.KeyChainActivity, in which you can choose the proper certificate.
I am able to do so, but once I execute my test class again, Appium waits for the .CredentialStorage Activity to get focused, which of course doesn’t happen since the PIN got entered before.
I don’t like having to restart the emulator for each run, so is there any possibility to wait for multiple Activities?
I found something in the documentation, but that didn’t work for me.
I’ve tried:
caps.setCapability(MobileCapabilityType.APP_WAIT_PACKAGE, “com.android.settings”);
caps.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY, “.CredentialStorage”);
and
caps.setCapability(MobileCapabilityType.APP_WAIT_PACKAGE, “com.android.keychain”);
caps.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY, “.KeyChainActivity, com.android.settings.CredentialStorage”);
and almost all variations but it seems like appium just appends the waitActivity to the waitPackage capability.
It throws errors like this:
error: Failed to start an Appium session, err was: Error: com.android.keychain/.KeyChainActivity, com.android.settings.CredentialStorage never started. Current: com.android.settings/.CredentialStorage
However, using the capabilities above and having the PIN entered before, Appium creates the session successfully.
To summarize:
- First run: app launch → com.android.settings.CredentialStorage → com.android.keychain.KeyChainActivity
- all following runs in the same emulator: app launch → com.android.keychain.KeyChainActivity
So how do I wait for different activities to become visible?
Any help is kindly appreciated, if you need me to provide more info or logs let me know.
On an other note: Wouldn’t it make sense to make a server flag or capability which causes Appium NOT to unlock the screen? You could then send sendKeys-Commands which enter the lock screen PIN…