Deploy device maintenance scripts (Perfecto IDE alternative)

With PerfectoActions, you can create device maintenance scripts that handle the cleanup, reboot, reservation, and retrieval of network settings in parallel and across all or specific devices in the Perfecto lab. In addition, you can set up scheduling for these scripts to run at the desired interval, depending on the devices involved. You can also view or delete old media repository items and list all or specific users automatically. Device manufacturers that do not support auto-connect on reboot are skipped automatically.

This non-flash, non-native, multi-threaded solution replaces the following Perfectonative automation commands: clean device, reboot device, and get network settings. For more details and samples, see this GitHub project: https://github.com/PerfectoMobileSA/Device_actions_reporter

Important: This document includes references to third-party products, Jenkins, TeamCity, and Microsoft Azure. The user interface and usage of third-party products are subject to change without notice. For the latest published information about Jenkins, see https://www.jenkins.io/doc/. For the latest published information about TeamCity, see https://www.jetbrains.com/teamcity/learn/. For the latest published information about Microsoft Azure, see https://learn.microsoft.com/en-us/azure/?product=popular.

The results appear in a fully responsive, dark-mode themed, accessible HTML report with direct access to available devices and the option to:

  • Search for devices and users in the displayed HTML table
  • View direct API results for clean and restart commands
  • Open your Perfecto cloud
  • Get information on device status, model, OS version, SIM operator graphs, and users.
  • View a complete device status and user list summary
  • View accurate, expandable graphs, also available in full-screen view
  • Download a full Get Devices List API response as well as a User API response based on your own requirements as a Microsoft Excel file

The following image shows a sample results page.

Why maintenance is important

Devices that form part of the individual clouds are real devices and as such not built for 24/7 usage under full load. Maintenance of these devices should therefore contain a reboot, among other checks, and be either run by a schedule (for example daily or weekly) or triggered by an action (for example before each main regression suite). The frequency depends on the amount of tests run and the model of devices. Generally, the more tests we execute against a specific device, and the older (or less reliable) the device is, the more often we should reboot the device.

A maintenance script or suite, which would consist of a number of maintenance actions to be performed, can be set up to run in parallel on specified devices.
Actions could include rebooting the device, recovering, resetting WiFi (switching off-on), verifying internet connectivity, verifying if the mobile network or WiFi is connected, installing and uninstalling required apps, and so on.

You can implement maintenance scripts in Appium/Selenium with a programming language of your choice, by using pure REST API calls, or by using PerfectoActions. Previously, it was also possible to use the Perfecto IDE, but with Flash being deprecated by the end of 2020, it is essential to adapt a different solution.

System configurations

Consider the following configuration settings:

  • At least 8 GB RAM
  • At least 2.20 GHz multicore processors

Prerequisites

Using PerfectoActions for your maintenance script requires that you:

  • Install Python version 3+ and set it as default.
  • Install pip. If you experience proxy issues when installing pip, see Configure an experimental proxy.
  • Run the following command from a command-line window:

    Copy
    pip3 install perfectoactions -U

Google Chrome and Apple Safari are the preferred browsers. If using Microsoft Internet Explorer, make sure to enable active scripting.

Usage

Copy
perfectoactions [-h] [-c cloud_name] [-s security_token]
                   [-d [device_list_parameters]]
                   [-u [user_list_parameters]]
                   [-t [Different types of Device Connection status]]
                   [-a [actions]] [-r [refresh]] [-o [output in html]]
                   [-l [shows customer logo]]


optional arguments:
-h, --help            show this help message and exit
-c cloud_name, --cloud_name cloud_name
                        Perfecto cloud name. (E.g. demo)
-s security_token, --security_token security_token
                        Perfecto Security Token/ Pass your Perfecto's username and password in user:password format
-d [device_list_parameters], --device_list_parameters [device_list_parameters]
                        Perfecto get device list API parameters to limit device list. Support all API capabilities which selects devices based on reg ex/strings, Leave it empty to select all devices
-u [user_list_parameters], --user_list_parameters [user_list_parameters]
                        Perfecto get user list API parameters to limit user list. Support all API capabilities which selects users based on applicable parameters, Leave it empty to select all users
-t [Different types of Device Connection status], --device_status [Different types of Device Connection status]
                        Different types of Device Connection status. Values: all. This will showcase all the device status like Available, Disconnected, un-available & Busy. Note: Only Available devices will be shown by default
-a [actions], --actions [actions]
                        Perfecto actions seperated by semi-colon. E.g. reboot:true;cleanup:true;get_network_settings:true
-r [refresh], --refresh [refresh]
                        Refreshes the page with latest device status as per provided interval in seconds
-o [output in html], --output [output in html]
                        output in html. Values: true/false. Default is true
-l [shows customer logo], --logo [shows customer logo]
                        shows client logo if valid official client website url is specified in this sample format: www.perfecto.io

Examples

Following is a list of usage examples.

Area Example Syntax to use
Device operations List all available devices
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>"
Device operations List all available devices with an optional feature to provide custom logo using the following syntax: -l "www.<<official website>>”
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -l "www.perfecto.io"
Device operations List all available devices using your Perfecto username and password
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<username/email>>:<<password>>"
Device operations List all devices irrespective of device status
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -t all
Device operations Reboot, clean up, and get network settings for all devices, in parallel
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -t "all" -a "reboot:true;cleanup:true;get_network_settings:true"
Device operations

Limit the selection of devices by applying any/multiple Get Devices List parameters and regular expressions using the following syntax: {param1}:{value1};{param2}:{value2}

Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -d "model:Galaxy S.*;description:.*Genesis;dynamicField.ipa:Test-Android.*"
Device operations Get network settings (such as airplane mode, WiFi, and data) for available Samsung Galaxy devices only, in parallel
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "get_network_settings:true" -d "model:Galaxy.*"
Device operations Reboot devices that are reserved by a specific user
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "reboot:true" -d "reservedTo:<<perfecto user email>>"

Reservation

Reserve device time, in minutes (minimum: 15). Can be combined with other device operations, such as cleanup.
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "reserve:15;cleanup:true" -d "model:Galaxy.*"
Repository cleanup Display older repository items using the following syntax: 
-a "clean_repo|false|do you have admin role? - true(false)|media repository locations|number of days to select items older than the current date"

The following example automatically displays repository media items older than 15 days.

Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "clean_repo|false|true|PUBLIC:John/Temp/,PRIVATE:Python,GROUP:John|15"
Repository cleanup Automatically delete older repository items using the following syntax:
-a "clean_repo|true|do you have admin role? - true(false) |media repository locations|number of days to select items older than the current date"

The following example automatically deletes and displays repository media items older than 15 days.

Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "clean_repo|true|true|PUBLIC:John/Temp/,PRIVATE:Python,GROUP:John|15"
User list limitation Limit or filter the user list using the following syntax: -u "{param1}:{value1};{param2}:{value2}"
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -u "roles:AUTOMATION;firstName:John"
General Re-run the same execution with a specified sleep time
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -r 1
General Skip output in HTML format (for faster results in a command-line window)
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -o false
General Override the count of parallel threads in case of limited CPU cores. In the code example, 2 parallel threads are defined.
Copy
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -p "2"

If you want to enable non-admin users to delete media repository files for users who have access to the same group folder, contact Perfecto Support.

Consider assigning a unique description or dynamicField for devices that are applicable for reboot and utilize the -d parameter for reboot. See the Limit the selection of the devices example.

Restriction: PerfectoActions is subject to the same restrictions and limitations as the Reboot device API, with regard to locked phones and limitations to reboot devices by certain manufacturers.

Configure an experimental proxy

Important: This setup has not been tested yet.

To configure an experimental proxy:

  1. Configure proxies by setting the following environment variables:

    HTTP_PROXY

    HTTPS_PROXY

    For example:

    Copy

    On Mac

    export HTTP_PROXY="10.10.1.10:3128"
    export HTTPS_PROXY="10.10.1.10:1080"
    Copy

    On Windows

    set http_proxy=http://proxy.myproxy.com
    set https_proxy=https://proxy.myproxy.com

  2. To use HTTPS basic authentication with your proxy on Mac, try this: https://user:password@host:port

    Copy
    On Mac
    export HTTP_PROXY="https://user:pass@10.10.1.10:3128/"
    export HTTPS_PROXY="https://user:pass@10.10.1.10:3128/"
    Copy

    On Windows

    set HTTP_PROXY="https://user:pass@10.10.1.10:3128/"
    set HTTPS_PROXY="https://user:pass@10.10.1.10:3128/"
    Restriction: Usernames and passwords cannot contain special characters such as :,@.

Set up scheduling

This section walks you through the steps for setting up the automatic scheduler on Windows, on Mac, or in Jenkins. Expand the steps that apply to you.