Run script-based instrumentation on Android apps

To run script-based instrumentation on Android apps, perform the following steps.

For supported environments, prerequisites, and limitations, see Script-based instrumentation for Android apps.

For examples, see Examples for Android script instrumentation.

If you run into any problems during the instrumentation process, see Troubleshooting script instrumentation for Android.

Step 1 | Obtain the Python script

The script to activate the instrumentation is called customInstrumentWrapperAndroid.py. You can retrieve the script from our Perfecto Code site.

Install the script on the workstation that will be used to perform the instrumentation, in a folder of your choice.

Step 3 | (Optional) Gather certificate information

If you want the instrumented app to be signed with your own certificate, make sure you have the following information ready:

  • Certificate file

  • Certificate key

  • Certificate user

  • Keystore password

These values are used to sign the app during instrumentation. If you don’t provide them, the app will be signed with a default debug certificate instead.

You may need to contact your DevOps or mobile development team to obtain this information if you don’t already have access to it.

Step 4 | Generate a security token

You need a Perfecto security token to authenticate the instrumentation script.

To generate the token:

  1. In the Perfecto UI, go to My profile > My security token.

  2. Click GENERATE SECURITY TOKEN.

  3. To copy the token for use in your script, click Copy to clipboard.

Alternatively, you can generate a security token using Perfecto's public API.

Step 5 | Run the instrumentation script

  1. Place the following items on the local workstation:

    • The applicaton file (mandatory)

    • The Python script (mandatory)

    • The token file (mandatory)

    • The certificate file (optional)

  2. Using the command line interface, run the customInstrumentWrapperAndroid.py script from the folder where it was installed, supplying the relevant parameters. To learn more about the available parameters, see Parameters for Android script instrumentation. For examples, see Examples for Android script instrumentation.

    Important: The path of the shell must be the path of the script.

    For Linux, use either the python or the python3 command, whichever activates Python 3.

    Copy

    Windows

    python customInstrumentWrapperAndroid.py
    Copy

    macOS

    python3 customInstrumentWrapperAndroid.py

When the instrumentation completes, a notification appears and the instrumented application file is copied to the target folder, indicated by the output folder parameter (see examples).

At every run, the application hash must be replaced. Otherwise, AWS uses the old application file and does not store a new one.

Step 6 | Upload the app to Perfecto

How you upload the instrumented application to Perfecto depends on whether you are a manual tester or an automation tester.

Make sure not to instrument the app again during the app installation process.

What's next?

When the app is instrumented, installed, and running on the device, you can inject sensory input. To learn more, see: