mardi 9 février 2016

Appium doesn't find launched appWaitActivity

So I'm testing an in-house Android application, which requires the user to select a certificate.

My set up is:

  • Mac OS X 10.10.5
  • Appium v1.4.16
  • Node v5.5.0
  • Appium java-client 3.3.0
  • JUnit 4.12

  • appPackage is set to "com.company.app"

  • appActivity is set to ".LoginCertificateChecker". Appium is able to launch this application (preinstalled on emulator/ real device). So that's working.

Now to the problem:

Android requires a lock screen PIN (or any other security mechanism) to secure the credential storage, I had to specify that. Appium bypasses the lock screen using its Unlock.apk, giving the AUT the main focus. Because of that, Android displays an alert activity (com.android.settings.CredentialStorage, see this picture), which prompts for the PIN. I have specified that in appWaitPackage and appWaitActivity. I enter the PIN using driver.findElement(...).sendKeys(myPIN), submit that and Android is happy.

It then displays another alert activity (this time "com.android.keychain.KeyChainActivity" see this picture), which shows all installed certificates.

Now since I didn't specify this Package & Activity in the desiredCapabilities, Appium times out with the error message:

error: com.android.settings/.CredentialStorage never started.
Current: com.android.keychain/.KeyChainActivity
info: [debug] Responding to client with error
{"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"com.android.settings/.CredentialStorage never started. Current: com.android.keychain/.KeyChainActivity"},"sessionId":"[...]"}

If I run the test again, using appWaitPackage="com.android.keychain" and appWaitActivity=".KeyChainActivity", my test succeeds.

However, I don't want to have to do so. So I found this in the appium 1.4 documentation:

If the ‘appWaitPackage’ and ‘appWaitActivity’ caps are specified, Appium automatically spins until those activities are launched. You may specify multiple wait activities for instance:
appActivity: ‘com.splash.SplashScreen’
appPackage: ‘com.splash’ appActivity: ‘.SplashScreen’
appPackage: ‘com.splash’ appActivity: ‘.SplashScreen,.LandingPage,com.why.GoThere’

So I changed the capabilities to:

caps.setCapability(MobileCapabilityType.APP_WAIT_PACKAGE, "com.android.settings, com.android.keychain");
caps.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY, ".CredentialStorage, .KeyChainActivity");

With that, Appium still fails, giving the error message:

info: [debug] Responding to client with error: {"status":33,"value"
{"message":"A new session could not be created. (Original error: com.android.settings, com.android.keychain/.CredentialStorage, .KeyChainActivity never started. 
Current: com.android.keychain/.KeyChainActivity)",
"origValue":"com.android.settings, com.android.keychain/.CredentialStorage, .KeyChainActivity never started. Current: com.android.keychain/.KeyChainActivity"},"sessionId":null}

It even fails to get the focused package & activity when I set the capabilities to:

caps.setCapability(MobileCapabilityType.APP_WAIT_PACKAGE, "com.android.settings, com.android.keychain");
caps.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY, "com.android.settings.CredentialStorage, com.android.keychain.KeyChainActivity");

Also note, that it didn't make a difference for me whether there's a space between the values or not.

So, am I missing something or is Appium simply not able to wait for multiple activities? Any hints and help is appreciated. If you need more info or logs let me know.

Aucun commentaire:

Enregistrer un commentaire