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

Last updated: Dec 19, 2017 12:02

By Philipp Schwarze

In some cases it may be interesting to see how certain parts of an application perform over time. This can be done by adding timers to a test, which is scheduled to run every x minutes.
This simple Maven based tool will help gather the timers from each executed run in an Excel file, removing the need to do this manually.
This enables users to quickly pinpoint inconsistent test runs, and dive into video and report.

How to add a timer to a test in Perfecto Native Automation

Without modification, when executed the tool will connect to the specified cloud, parse the execution report for any Get Timer functions, and output the results including the timer name into the specified Excel.

For that it is necessary to wrap the action(s) you want to record with Timer start and Timer end functions, as well as Get Timer. These can be found under the Script section of the general Functions:


Adding Timer to a Native Test


Ensure to address the timer with the same name in all three functions, and chose UX timer if the UserExperience Timer is to be captured. 
Timing a simple Text checkpoint for example may then look like this:

Adding Timer to a native Test

Tests can then be triggered manually, or programmatically through a CI Server, the Perfecto Scheduler or using the REST API.

How to use the Timer Extractor

The TimerToExcelExctractor project can be found at the following location:

https://github.com/PerfectoCode/Community-Samples/tree/master/TimerToExcelExtractor

 

Parameters

The Extractor is a Maven Project containing a main function. When executing, it is required to define the Maven goals as well as commandline parameters.

The complete string should be

clean install exec:java -Dexec.mainClass="com.excelReadTimer.TimerExtractor" -Dexec.args="url user password testPath excelLocation timeZone TypeOfExecution"


  • Url. The Perfecto Lab url (e.g. mycloud.perfectomobile.com)
  • Username (e.g. myuser@perfectomobile.com)
  • Password. the encrypted password (see paragraph on "Encrypting Password" for further information)
  • TestPath. the path to the test (e.g. for above tests under MyScripts/timerTest the path would be PRIVATE:timerTest.xml)
  • ExcelLocation. the desired location for the output Excel file (e.g. c:\timerResults.xlsx)
  • TimeZone. the desired time zone of the time stamp added to the Excel for each execution (eg. GMT-4, see https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html for options)
  • TypeOfExecution. LastSingleExecution or AllAvailableExecutions. LastSingleExecution will add only the very last execution to the Excel, as long as it has not been added.
    AllAvailableExecutions will add all available Executions, the number depends on the configuration.

Encrypting Password

The example implementation uses below password encryption class:

Add password encryption/decryption in a Selenium framework

 

The TimerToExcelExtractor project contains the PasswordEncryptTester class, which can easily be modified and run to obtain an encrypted version of a password.
Simply change the myPassword variable, as well as the mySalt and execute the main function.

public class PasswordEncryptTester {
 static String myPassword = "PasswordToEncrypt";
 static String mySalt = "Perfecto";

 public static void main(String[] args) {
         String a = StringEncrypt.encryptXOR(myPassword, mySalt);
        System.out.println(a);
}}

 

How to execute from Eclipse

As an example for an IDE, here are the steps to execute the project directly from Eclipse.

  • Add a new Run Configuration (Run -> Run Configuration -> Maven Build -> New Launch Configuration)

 

  • Specify the Maven goals and arguments as under Parameters then Apply and Run e.g.:

 

How to configure running from Jenkins

When creating a new Maven build project, ensure to set Goals and Options to contain the required params, e.g.:

If the project is to be executed after another job- for example after triggering the Perfecto Test containing the timers, the job can be configured to execute right after the test: