Android
Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .
Prior to instrumentation, you need to configure either of the following app properties:
-
Set android.instrument.fingerprint to true if your app implements a standard fingerprint authentication dialog.
-
Set android.instrument.fingerprint.secure to true if your fingerprint implementation involves security authentications for the responses received from the user.
After instrumenting the Application with mock authentication property the application may not support manual authentication (can't authenticate with a real fingerprint).
In order to use setMockAuthenticationReply command on your application, your application needs to be Instrumented, you can achieve this by:
-
Import or re-instrument your app via Application Manager or use install command with instrument=true.
- For iOS applications, you can also use manual instrumentation to instrument the app manually. For more information see SeeTestAutomation - Manually Instrumenting iOS Applications.
It is recommended to use this command before the application. i.e., the command sets the desired reply for future authentication requests.
Examples
The following examples are demonstrated in the BiometricAuthentication sample application. Note that some of the dialogs can change, depending on the device vendor and Android version.
Initial Application View
Success Result
Executing the following to display a "Purchase successful" message.
client.setAuthenticationReply("AUTHENTICATION_SUCCEEDED", 0);
client.click("NATIVE", "xpath=//*[@text='PURCHASE']", 0, 1);
Failure Result
Executing the following to display the authentication request with a failure message.
client.setAuthenticationReply("AUTHENTICATION_FAILED", 0);
client.click("NATIVE", "xpath=//*[@text='PURCHASE']", 0, 1);
It will result in
Cleare the Mocked Reply
To set a different reply or to reset the mocked authentication reply state, close the dialog if open and then execute:
client.setAuthenticationReply("CLEAR_MOCK", 0);
client.click("NATIVE", "xpath=//*[@text='PURCHASE']", 0, 1);
This results in displaying the original dialog, which is waiting for real user authentication.
More information
The application used in the examples demonstrates the use of the new Biometric API, which replaces FingerprintManager, which is deprecated since API level 28.
In Android, mocking authentication is supported for applications which use the native implementation.
Mock authentication is not supported for third party libraries.