Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Apr 07, 2021 11:34

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 Perfecto native automation commands: clean device, reboot device, and get network settings. For more details and samples, see this GitHub project:

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
  • Raise a Perfecto support ticket
  • Open your Perfecto cloud
  • Navigate to Perfecto documentation
  • 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.

On this 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

We recommend the following configuration settings:

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


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:

    pip3 install perfectoactions -U
Note: Google Chrome and Apple Safari are the preferred browsers. If using Microsoft Internet Explorer, make sure to enable active scripting.


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:


Following is a list of usage examples.

AreaExampleSyntax to use
Device operations

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

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

perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -d "model:Galaxy S.*;description:.*Genesis;dynamicField.ipa:Test-Android.*"
Get network settings (such as airplane mode, WiFi, and data) for available Samsung Galaxy devices only, in parallel
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "get_network_settings:true" -d "model:Galaxy.*"
Reboot devices that are reserved by a specific user
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "reboot:true" -d "reservedTo:<<perfecto user email>>"
ReservationReserve device time, in minutes (minimum: 15). Can be combined with other device operations, such as cleanup.
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "reserve:15;cleanup:true" -d "model:Galaxy.*"
Repository cleanupDisplay 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 provided date"

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

perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "clean_repo|false|true|PUBLIC:John/Temp/,PRIVATE:Python,GROUP:John|15"
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 provided date"

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

perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -a "clean_repo|true|true|PUBLIC:John/Temp/,PRIVATE:Python,GROUP:John|15"
User list limitationLimit or filter the user list using the following syntax: -u "{param1}:{value1};{param2}:{value2}"
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -u "roles:AUTOMATION;firstName:John"
GeneralRe-run the same execution with a specified sleep time
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -r 1
Skip output in HTML format (for faster results in a command-line window)
perfectoactions -c "<<CLOUD NAME>>" -s "<<SECURITY TOKEN>>" -o false
Override the count of parallel threads in case of limited CPU cores. In the code example, 2 parallel threads are defined.
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.
  • We recommend that you assign 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.
  • 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. For details, see Devices restart Limitation. However, the latest version of PerfectoActions automatically skips, when trying to reboot, any manufacturers mentioned under Devices Restart Limitation.

Configure an experimental proxy

Note: This setup has not been tested yet.

To configure an experimental proxy:

  1. Configure proxies by setting the following environment variables:
    For example:

    On Mac
    export HTTP_PROXY=""
    export HTTPS_PROXY=""
    On Windows
    set http_proxy=
    set https_proxy=
  2. To use HTTPS basic authentication with your proxy on Mac, try this: https://user:password@host:port

    On Mac
    export HTTP_PROXY="https://user:pass@"
    export HTTPS_PROXY="https://user:pass@"
    On Windows
    set HTTP_PROXY="https://user:pass@"
    set HTTPS_PROXY="https://user:pass@"
    Note: In usernames and passwords, avoid using 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.

Steps for Windows
  1. Open Task Scheduler.
  2. Create a new task and enter a descriptive name.

     Click to view image
  3. On the Triggers tab, click New.
  4. In the New Trigger dialog box, set the trigger as preferred. For example, select Daily to run the task daily.

     Click to view image
  5. On the Actions tab, click New.
  6. Browse to the actions.bat file. A sample .bat file is available here:
  7. Edit the actions.bat file to supply your preferred arguments to perfectoactions on line 2.
    perfectoactions are triggered based on the trigger configuration.

     Click to view image

    Results will be displayed as shown in the following image, provided -o is not set to false in perfectoactions arguments.

     Click to view image

    Note: The report will be ready when the execution is complete.

Steps for Mac
  1. To get the physical path of perfectoactions, in a terminal window, type which perfectoactions.

     Click to view image
  2. Download a sample shell file from here:
  3. Edit the downloaded .sh file by setting the physical path of perfectoactions and applicable arguments.
  4. In a terminal window, navigate to the location to which you downloaded the sample shell file ( and run the following command:

    chmod +x ./
  5. To grant cron full disk access, in System Preferences > Security & Privacy, on the Privacy tab, drag /usr/sbin/cron into the Full Disk Access area.

     Click to view image
  6. In a terminal window, run the following command:

    crontab -e
  7. Press i and enter the following:

    {cron} /{path of}/ >/{path of logs}/stdout.log 2>/{path of error logs}/stderr.log

    For example:
    30 2 * * * /Users/genesisthomas/Downloads/ >/tmp/stdout.log 2>/tmp/stderr.log

    Note: 30 2 * * * runs the cron job at 2:30 am every day.
  8. Press :wq! to save the file and click on OK in the confirmation form that opens.

     Click to view image
  9. To see whether the cron job is enabled, run the following command:

    crontab -l
  10. Verify the results.

     Click to view image

    Note: The report will be ready when the execution is complete.

Steps for Jenkins
  1. On Windows only: Start the Jenkins service logged on with a local user account.
  2. Log in to Jenkins.
  3. Go to Manage Jenkins > Manage Plugins and install the HTML Publisher plugin.
  4. Back on the Manage Jenkins page, navigate to the Script Console.
  5. In the Script Console, paste the following and click Run

    System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
     Click to view image
  6. Clear the browser history and cache, restart the browser, and log in to Jenkins.
  7. In Jenkins, create a new freestyle job.
  8. In the Build triggers section, enable the Build periodically option.
  9. In the Schedule section, enter your preferred cron schedule. For example, 30 2 * * * will run the job at 2:30 am every day.
  10. In the Build Environment section, enable the Delete workspace before build starts option.
  11. Add a build step, as follows.
    On Windows, execute a Windows batch command with the following commands included:

    pip install -U perfectoactions
    del /s /q "C:\Users\<<Windows user name>>\AppData\Local\Temp\output\*.*"
    perfectoactions -c <<CLOUD NAME, e.g. demo>> -s "<<SECURITY TOKEN>>" <<ADDITIONAL ARGUMENTS AS APPLICABLE>>
    xcopy /s "C:\Users\<<Windows user name>>\AppData\Local\Temp\output" .
    EXIT /B
     Click to view image

    On Mac, execute a shell with the following commands included:

    <<PATH TO PIP>>/pip3 install -U perfectoactions
    rm -rf "/tmp/output/*.*"
    perfectoactions -c <<CLOUD NAME, e.g. demo>> -s "<<SECURITY TOKEN>>" <<ADDITIONAL ARGUMENTS AS APPLICABLE>>
    cp /tmp/output/result.html .
     Click to view image


    • Update the preferred values within <<>> as applicable.
    • To find the path of pip3/perfectoactions, in a terminal window, use the which command. For example, which pip3 will show the path of pip3.
  12. Add the following post-build actions:
    1. Archive artifacts with files in the results.html archive (see image above)
    2. Publish HTML reports with index page: result.html (see image above)
  13. To find the results.html being published as an HTML report, run the job.

     Click to view image

    Note: The report will be ready when the execution is complete.

Steps for TeamCity
  1. In TeamCity, create a new project.

     Click to view image
  2. Provide the repository URL and your GitHub credentials. Then click Proceed twice.

     Click to view image

    TeamCity autodetects the sample shell and bat scripts.

  3. Select the required script (.bat on Windows and .sh on Mac) and click Use selected.

     Click to view image

  4. Click Edit.

     Click to view image

  5. In the Custom script field, edit the code with trailing sample for Mac (sample) by updating your cloud name, the Perfecto security token, and additional arguments, as applicable. Then click Save.

    pip3 install -U perfectoactions
    rm -rf  "/tmp/output/*.*"   
    cp /tmp/output/result.html .
     Click to view image

  6. Under General settings, in the Artifact paths field, enter result.html. Then click Save.

     Click to view image
  7. To configure the build schedule, follow the instructions at

  8. To execute PerfectoActions in TeamCity, click Run. Then view the results on the Artifacts tab.

     Click to view image