Header

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Introduction

Though Qualitia covers most of the actions required for automation testing, there might still be a need to add some more actions to Qualitia based on the project requirements. Qualitia allows you to develop your own actions and make them available to use while automating test cases for the application under test.
The custom action module allows you to develop and maintain these actions in a convenient way.
This module provides:

  • A guided and easy to follow guidelines to develop custom actions,

  • Make code templates, required dependencies, and sample codes easily available to anyone who can create custom actions,

  • Maintain the custom action code just like you maintain tasks and test cases using a version control tool like SVN or Git, and

  • Share these custom actions with other project members for use.

Working with Custom Actions for Web and Mobile Projects

After you import all your existing custom actions in Qualitia, you can now create, modify, search, or view the custom action codes in Qualitia automation studio itself. In the cases of multi user scenario, you can share these actions easily with other team members just as you share your tasks and test cases.

Also, any of the project members can update the code using an Eclipse IDE based on the requirements. You can launch an Eclipse IDE from Qualitia automation studio itself.

Importing Existing Custom Actions Created in Previous Qualitia Versions

If you have created custom actions using a Qualitia version before v7.0.0, then you can import your existing set of custom actions into Qualitia. Importing custom actions is simple 3 step process.

 1. Gather or generate all java source files at one place.

In order to import and streamline the custom actions with other project data in Qualitia, you must add all the java source files at one place. In case you do not have source files for some actions, you can generate the source code files easily using these commands mentioned below.

  1. Launch command prompt.

  2. Navigate to the %localappdata%\QualitiaWDClient\app-7.1.0\Dist folder.

  3. Enter the following command:

    “java -jar jd-cli.jar "<CLASS_FILE_SOURCE_PATH>" -od "<DESTINATION_FOLDER_TO_SAVE_SOURCE_CODE>"

    C:\Users\<HOSTNAME>\AppData\Local\QualitiaWDClient\app-7.1.0\Dist>java -jar jd-cli.jar "D:\ClassFiles" -od "D:\JavaFiles"
    21:21:06.078 INFO  jd.cli.Main - Decompiling D:\ClassFiles
    21:21:06.095 INFO  jd.core.output.DirOutput - Directory output will be initialized for path D:\JavaFiles
    21:21:06.412 INFO  jd.core.output.DirOutput - Finished with 2 class file(s) and 1 resource file(s) 

    Post executing this command, source code files will be added at the destination folder. You can use them now to build and compile Eclipse project.


 2. Create an Eclipse project and compile the project with all the custom actions.

To create and compile custom action project:

  1. Launch Eclipse and create a new java project using an execution environment as JRE 1.8.

  2. Set the bin folder as an output folder.

  3. Add new folder and name it as lib.
    The complete folder hierarchy will look something like this in the project directory.



  4. Add all the existing custom action files in this directory.
    Before you start adding custom action-related data into these sub folders, ensure that the code is working fine.

    1. Add all the dependency files in the lib folder. 

    2. Add all the compiled class files in the bin folder.

    3. Add all the java source files in the src folder. 
      Ensure you add all your dependent jars in lib folder and provide the relative path for these jars in Build Path with the correct sequence.

  5. Compile and build the Eclipse project.
    Actions are now ready to be imported.


 3. Import custom action code in Qualitia Project.

You can import the existing set of custom actions in Qualitia to share with the other project members easily.

(info) Ensure the class files you are providing have all the custom actions functions present for which you have provided the metadata. A single class file can contain functions for multiple custom actions.

  1. Log on to automation studio as a user with Manage Custom Action Code privileges. 

  2. Navigate to the project in which you want to import the custom action code and then click Develop > Custom Actions.
    You will see the notification about importing custom actions on the top. This option is visible only if the project contains any custom actions that are not yet imported.

  3. Click Import.

  4. Provide path to the the Eclipse project which we have created and compiled earlier.

  5. After importing all the custom action files successfully, click Close.
    Eclipse project directory will be copied under Qualitia project path with all the sub-folders mentioned earlier (bin, lib, src, and so forth).
    The Custom Action Repository Path under Configuration Settings will be set automatically to this new directory created under Qualitia Project Path.

  6. In case there are any issues while importing the actions, these will be listed which can be exported in the HTML report.

  7. Refer to the troubleshooting section to resolve the errors.

    In case you are using any version control system (Bitbucket or SVN), you need to push and commit this java project folder into the repository manually for the first time and all the Qualitia clients must pull the same on their respective systems. This is a one-time activity. Changes made to the custom actions thereon will be pushed automatically.



Creating a Custom Action for a Web/Mobile Project

Pre-Requisites

Creating New Custom Actions

  1. From the Expand Menu, click Develop.

  2. Click the Custom Actions tab.

  3. Click the Add Button (  ) or Create Custom Action button.
    The Custom Actions screen appears.

  4. Select Base Class.
    (warning) The Custom Object Class file name including its file path should not exceed 256 characters when you are using Git/Bitbucket as a source control system for maintaining project artifacts.

  5. Do one of the following:

    • To add a new Qualitia Class:

      1. Click the Plus button next to Custom Object Class to add a custom object class by mapping to the Qualitia Class that you want to add.

      2. Enter the java class file name without its extension along with the package name (if required), in Qualitia Class.

    • To select a pre-defined Qualitia Class that is mapped to a Custom Object Class:

      • From the Custom Object Class drop-down list, select a pre-defined custom object class.
        The associated Qualitia Class is selected automatically.

        Points To Know

        • For example, if you add a Qualitia Class "com.security.login", then this file creates a package and a java file called as "com.security" and "login.java" respectively.
        • The Custom Object Class is a user-friendly alternate name for a Qualitia Class, which you can specify.




  6. Enter Action Name, Description and Function Name for the action to be created.

  7. In the Properties section, click Add.
    A new line will be added in the grid.

  8. Add Parameter Name, Description, ArgDataType for the parameter, and select whether this parameter is mandatory.

    1. To save the action, click Save.

    2. To save the action and launch the code template in Eclipse IDE, click Save and Launch Eclipse.

  9. Close the Welcome on the IDE window to see your auto-generated custom action code template.

  10. Import the pre-created Custom Action Java project workspace into Eclipse workspace.
    (info) This is a one-time activity for a project.

    1. To import the pre-created workspace, right-click Package Explorer, and select Import from the context-menu.

    2. On the Import window, under the General section, select Existing Projects into Workspace and then click Next.

    3. In the Select root directory section, click the Browse button, select <PROJECTNAME>_QASJavaproject and click Finish.
      You will find this directory under Qualitia project path.



  11. In Eclipse IDE, from the Window menu, select Preferences.

  12. Select General > Workspace > Select Refresh using native hooks or polling.

  13. Click Apply and Close.

  14. Ensure you do not change the method signature and provide only the method body. Changing the signature in code may break your action in Qualitia.

  15. In the editor, add the custom action code in the provided template for your custom action.

  16. To add the dependent jars, do the following in the order listed:

    1. Add the dependent jar files in the lib folder under the project.

    2. Right-click the Project, point to Build Path, and then select Configure Build Path.

    3. Click Libraries > Add JARs.

    4. Under Jar Selection window, expand the Project folder.

    5. Under the lib folder, select the dependent Jar, and click Ok

    6. Click Apply and Close.

  17. Build the project and close the Eclipse IDE.
    To work this custom action code in the Qualitia automation test cases, you must build the project successfully.
    You can now use this newly created custom action while developing task and test cases in Qualitia.


Once you have closed the Eclipse IDE, Qualitia automatically commits the code to the version control system (if configured) and makes the code available to other Qualitia project members.


Recommendations and Rules for Custom Actions

Generic Recommendations

  • The parameter data types supported by Qualitia are String and Array. If an array parameter is used in Qualitia for the custom action, then custom action parameter should be of the type Object in Custom Action function. The parameter can then be type-casted into the data type which is required in the action.
    For example, the object parameter can be type-casted into the array list.

  • Based on the standard Java coding rules, actions should not be created in the default package. For better maintenance, it is recommended to use user-defined packages for development.

  • It is recommended to put a prefix when defining a name for new custom actions for easy identification.

  • No two custom actions can have the same function name in the same class. Function overloading is not allowed. Duplicate function names in different classes are allowed (not recommended). 

  • Once the action is mapped into Qualitia and used in a test case, do not change the existing signature or other details of the actions or the classes created. The functionality of the action can be modified. Do not delete the custom actions or custom classes that are used in test cases.

  • If the custom action belongs to any object type (such as WebEdit, WebElement, and so forth), ensure you add the objectInfo data type parameter while developing the code of an action.

  • While mapping actions into Automation Studio, it is important to map the action using <package.class> hierarchy. 

  • Objects should be added under appropriate Qualitia classes while mapping custom actions into Qualitia Automation Studio

New Recommendations from Qualitia v8.0.0

Making a New Class for Recommendations

package <QASpackagename>; 

import com.qualitia.execution.ActionResponse; 
 import com.qualitia.execution.ApplicationLogger; 
 import com.qualitia.models.testcase.ExecutionResult; 
 import com.webdriverfw.Wrappers.General; 

 <QASimportlist> 

 

 public class <QASclassname> extends General { 

 

 //Define your customs actions here 

 

 }

Writing Custom Actions in the Accepted Format

   package <QASpackagename>; 

import com.qualitia.execution.ActionResponse;   import com.qualitia.execution.ApplicationLogger;   import com.qualitia.models.testcase.ExecutionResult;   import com.webdriverfw.Wrappers.General; 

  <QASimportlist> 

  

  public class <QASclassname> extends General { 

  

  //Define your customs actions here 

  

  }


 public ActionResponse <QASmethodname>(<QASparametername>) { 

     

     ActionResponse actionResponse = getActionResponse(); 

     ApplicationLogger applicationLogger = actionResponse.getApplicationLogger(); 

     actionResponse.setExecutionResult(ExecutionResult.FAILED); 

     try { 

               // Your code here... 

             

           applicationLogger.writeToInfoLog(""); 

           actionResponse.setMessage("Successful message"); 

           actionResponse.setExecutionResult(ExecutionResult.PASSED); 

        } catch (Exception ex) { 

           applicationLogger.writeToErrorLog("Exception message", ex); 

           actionResponse.setMessage(“Failed Message”, FailureCategory); 

           actionResponse.setExecutionResult(ExecutionResult.FAILED); 

        } 

        return actionResponse; 

}  

ApplicationLooger

  • applicationLogger.writeToInfoLog(""); 

  • applicationLogger.writeToErrorLog(""); 

  • Info Log

  • Error Log

Show Link of File in Info Log Section 

Setting an Execution Result

  • ExecutionResult.PASSED is used to set when the action is passed.

  • ExecutionResult.FAILED is used to set when the action is failed. 

  • ExecutionResult.DEFECT is used to set when the action has a defect. 

  • ExecutionResult.NOT_EXECUTED is used to set when the action halts the execution.  

In Older Versions before 8.0.0 :  

    public int EqualStrings(String a, String b)  

    {  

    if(a.equals(b))  

    {  

    DataLogger.writeToDebugAndInfoLogs("they are equal");  

    return 0;  

    }  

    else  

    {  

    DataLogger.writeToDebugAndInfoLogs("they are not equal");  

    return 1;  

    }  

    }  

  

    In Qualitia 8.0.0 Version :  

    public AcionResponse EqualStrings(String a, String b)  

    {  

    ActionResponse actionResponse = getActionResponse();  

    if(a.equals(b))  

    {  

    actionResponse.setMessage("they are equal");  

    actionResponse.setExecutionResult(ExecutionResult.PASSED);  

    return actionResponse;  

    }  

    else  

    {  

    actionResponse.setMessage("they are not                                                                                equal”,FailureCategories.Category.INVALID_DATA);  

    actionResponse.setExecutionResult(ExecutionResult.FAILED);  

    return actionResponse;  

    }  

    }

 Adding a Failure Category for a Custom Action

package com.webdriverfw.Wrappers; 

 Import com.qualitia.execution.failureclassifications.FailureClassificatio; 

 public enum MyCategoriesEnum implements FailureClassification { 

    MY_CUSTOM_CATEGORY1("This is my custom category 1"), 

    MY_CUSTOM_CATEGORY2("This is my custom category 2"); 

  

    private String name; 

  

    MyCategoriesEnum(String s) { 

        name = s; 

    } 

   public String getCategory() { 

        return name; 

    } 

}   

 


actionResponse.setMessage("message",FailureCategories.CustomCategory.NEW_CUSTOM_CATEGORY1);


actionResponse.setMessage("message",FailureCategory.newCategory("Categoryname")); 


package com.webdriverfw.Wrappers; 

 public class MyCategoriesConstants { 

   public static final String MY_CUSTOM_CATEGORY3 = "This is my custom category 1"; 

    public static final String MY_CUSTOM_CATEGORY4 = "This is my custom category 2"; 

} 


actionResponse.setMessage("message",FailureCategory.newCategory(MY_CUSTOM_CATEGORY3)); 

Qualitia Public APIs for Custom Actions


Debugging a Custom Action

  1. Do in the following order listed to create necessary test artifacts:

    1. Create a test case and include the custom action that you want to debug at the appropriate step. For more information, refer to /wiki/spaces/T2/pages/2681539278

    2. From the test case editor, click Run to dry run the test case to verify whether the custom action is hit.

    3. Create a test suite that contains the test case. For more information, refer to Creating a Suite.

    4. Create an offline suite using the test suite. For detailed instructions, refer to Creating an Offline Package.

  2. To add the required files for debugging the custom action:

    1. Open the custom action you want to debug in the Eclipse project.

    2. Add the TestHarness.Java file for the custom action in the Eclipse project.

    3. Add the Config Folder in the Eclipse project.

    4. In the config folder, open the startupSettings.json file, and specify the location of the offline suite for “SuitesDir”.
      For example: "SuitesDir":"D:/Qualitia Offline/Suite1"

  3. Insert a breakpoint at an appropriate line number in the custom action.

  4. Start debugging the TestHarness.Java file.

  5. The test suite execution starts.
    When the custom action is executed, the execution stops at the breakpoint you have inserted.
    You can go ahead and debug the custom action.

To specify Java system properties before executing the test suite.

  1. From the config folder in the custom action of Eclipse, open the QualitiaSystemProperties.json.

  2. In the QualitiaSystemProperties.json file, enter the key-value pairs in the following format:

    1. {"key1": "value1",

      "key2": "value2",

      .

      .

      "keyN": "valueN"}

  3. Save the file.   

Troubleshooting (Custom Action Module)

Import Custom Action Cannot be continue due to following errors;...

Resolution:

Updating Qualitia Project Path

Re-importing this java project is mandatory. Else, the user will not be able to access updated custom actions.  This is a one-time activity.

  1. Ensure you clone all the project data to the new directory.
    This includes Test cases, Tasks, Custom actions, and Java project folders (which hold all the latest custom action code).

  2. Remove the existing project from the workspace.

  3. To import the cloned java project from the new directory, right-click Package Explorer, and select Import from the context menu.

  4. On the Import window, under the General section, select Existing Projects into Workspace and then click Next.

  5. In the Select root directory section, click the Browse button, select <PROJECTNAME>_QASJavaproject and click Finish.
    This is in the new directory where you have cloned the Qualitia project data.

  6. Select General > Workspace > Select Refresh using native hooks or polling.

  7. Click Apply and Close.

Custom Action Custom Files are Not Pushed to Project Path GIT Repository

  1. Open the Eclipse Project.

  2. Click Windows > Preferences > Teams > Git > Projects.

  3. In the right side of the Preference dialog box, under Projects, deselect the Automatically ignore derived resources by adding them.gitignore checkbox.

Other Validations

Validation Error

Resolution

.classpath file is not present in your Eclipse project location 

Ensure that the Eclipse project was built successfully after adding all required artifacts (lib, bin, src folders) to it. This will create a .classpath file. 

.class files are not present in your Eclipse project location 

Collect the required compiled .class files and add them to the Eclipse project (under bin folder). Names of the required files is mentioned in the report.

Jar files mentioned in .classpath in your Eclipse project location

Collect all the required jar files and add them to your Eclipse project directory (under lib folder).

Java source files are not present in your Eclipse project location 

You need to generate the source code from the compiled class files and add them into the src folder under Eclipse project directory. For more information on the creating the source files, refer to the Importing Existing Custom Actions Created in Previous Qualitia Versions section. 

Once you have fixed all the errors mentioned above, you can continue importing custom actions in Qualitia. 

Working with Custom Actions for Desktop Projects

Importing Existing Custom Actions Created in Previous Qualitia Versions

 1. Gather or generate all java source files at one place.

In order to import and streamline the custom actions with other project data in Qualitia, you must add all the java source files at one place. In case you do not have source files for some actions, you can generate the source code files easily using these commands mentioned below.

  1. Launch command prompt.

  2. Navigate to the %localappdata%\QualitiaWDClient\app-7.1.0\Dist folder.

  3. Enter the following command:

    “java -jar jd-cli.jar "<CLASS_FILE_SOURCE_PATH>" -od "<DESTINATION_FOLDER_TO_SAVE_SOURCE_CODE>"

    C:\Users\<HOSTNAME>\AppData\Local\QualitiaWDClient\app-7.1.0\Dist>java -jar jd-cli.jar "D:\ClassFiles" -od "D:\JavaFiles"
    21:21:06.078 INFO  jd.cli.Main - Decompiling D:\ClassFiles
    21:21:06.095 INFO  jd.core.output.DirOutput - Directory output will be initialized for path D:\JavaFiles
    21:21:06.412 INFO  jd.core.output.DirOutput - Finished with 2 class file(s) and 1 resource file(s) 

    Post executing this command, source code files will be added at the destination folder. You can use them now to build and compile Eclipse project.


 2. Create an Eclipse project and compile the project with all the custom actions.

To create and compile custom action project:

  1. Launch Eclipse and create a new java project using an execution environment as JRE 1.8.

  2. Set the bin folder as an output folder.

  3. Add new folder and name it as lib.
    The complete folder hierarchy will look something like this in the project directory.



  4. Add all the existing custom action files in this directory.
    Before you start adding custom action-related data into these sub folders, ensure that the code is working fine.

    1. Add all the dependency files in the lib folder. 

    2. Add all the compiled class files in the bin folder.

    3. Add all the java source files in the src folder. 
      Ensure you add all your dependent jars in lib folder and provide the relative path for these jars in Build Path with the correct sequence.

  5. Compile and build the Eclipse project.
    Actions are now ready to be imported.


 3. Import custom action code in Qualitia Project.

You can import the existing set of custom actions in Qualitia to share with the other project members easily.

(info) Ensure the class files you are providing have all the custom actions functions present for which you have provided the metadata. A single class file can contain functions for multiple custom actions.

  1. Log on to automation studio as a user with Manage Custom Action Code privileges. 

  2. Navigate to the project in which you want to import the custom action code and then click Develop > Custom Actions.
    You will see the notification about importing custom actions on the top. This option is visible only if the project contains any custom actions that are not yet imported.

  3. Click Import.

  4. Provide path to the the Eclipse project which we have created and compiled earlier.

  5. After importing all the custom action files successfully, click Close.
    Eclipse project directory will be copied under Qualitia project path with all the sub-folders mentioned earlier (bin, lib, src, and so forth).
    The Custom Action Repository Path under Configuration Settings will be set automatically to this new directory created under Qualitia Project Path.

  6. In case there are any issues while importing the actions, these will be listed which can be exported in the HTML report.

  7. Refer to the troubleshooting section to resolve the errors.

    In case you are using any version control system (Bitbucket or SVN), you need to push and commit this java project folder into the repository manually for the first time and all the Qualitia clients must pull the same on their respective systems. This is a one-time activity. Changes made to the custom actions thereon will be pushed automatically.



Creating a Custom Action for a Web/Mobile Project

Pre-Requisites

Creating New Custom Actions

  1. From the Expand Menu, click Develop.

  2. Click the Custom Actions tab.

  3. Click the Add Button (  ) or Create Custom Action button.
    The Custom Actions screen appears.

  4. Select Base Class.
    (warning) The Custom Object Class file name including its file path should not exceed 256 characters when you are using Git/Bitbucket as a source control system for maintaining project artifacts.

  5. Do one of the following:

    • To add a new Qualitia Class:

      1. Click the Plus button next to Custom Object Class to add a custom object class by mapping to the Qualitia Class that you want to add.

      2. Enter the java class file name without its extension along with the package name (if required), in Qualitia Class.

    • To select a pre-defined Qualitia Class that is mapped to a Custom Object Class:

      • From the Custom Object Class drop-down list, select a pre-defined custom object class.
        The associated Qualitia Class is selected automatically.

        Points To Know

        • For example, if you add a Qualitia Class "com.security.login", then this file creates a package and a java file called as "com.security" and "login.java" respectively.
        • The Custom Object Class is a user-friendly alternate name for a Qualitia Class, which you can specify.




  6. Enter Action Name, Description and Function Name for the action to be created.

  7. In the Properties section, click Add.
    A new line will be added in the grid.

  8. Add Parameter Name, Description, ArgDataType for the parameter, and select whether this parameter is mandatory.

    1. To save the action, click Save.

    2. To save the action and launch the code template in Eclipse IDE, click Save and Launch Eclipse.

  9. Close the Welcome on the IDE window to see your auto-generated custom action code template.

  10. Import the pre-created Custom Action Java project workspace into Eclipse workspace.
    (info) This is a one-time activity for a project.

    1. To import the pre-created workspace, right-click Package Explorer, and select Import from the context-menu.

    2. On the Import window, under the General section, select Existing Projects into Workspace and then click Next.

    3. In the Select root directory section, click the Browse button, select <PROJECTNAME>_QASJavaproject and click Finish.
      You will find this directory under Qualitia project path.



  11. In Eclipse IDE, from the Window menu, select Preferences.

  12. Select General > Workspace > Select Refresh using native hooks or polling.

  13. Click Apply and Close.

  14. Ensure you do not change the method signature and provide only the method body. Changing the signature in code may break your action in Qualitia.

  15. In the editor, add the custom action code in the provided template for your custom action.

  16. To add the dependent jars, do the following in the order listed:

    1. Add the dependent jar files in the lib folder under the project.

    2. Right-click the Project, point to Build Path, and then select Configure Build Path.

    3. Click Libraries > Add JARs.

    4. Under Jar Selection window, expand the Project folder.

    5. Under the lib folder, select the dependent Jar, and click Ok

    6. Click Apply and Close.

  17. Build the project and close the Eclipse IDE.
    To work this custom action code in the Qualitia automation test cases, you must build the project successfully.
    You can now use this newly created custom action while developing task and test cases in Qualitia.


Once you have closed the Eclipse IDE, Qualitia automatically commits the code to the version control system (if configured) and makes the code available to other Qualitia project members.


Recommendations and Rules for Custom Actions

Generic Recommendations

  • The parameter data types supported by Qualitia are String and Array. If an array parameter is used in Qualitia for the custom action, then custom action parameter should be of the type Object in Custom Action function. The parameter can then be type-casted into the data type which is required in the action.
    For example, the object parameter can be type-casted into the array list.

  • Based on the standard Java coding rules, actions should not be created in the default package. For better maintenance, it is recommended to use user-defined packages for development.

  • It is recommended to put a prefix when defining a name for new custom actions for easy identification.

  • No two custom actions can have the same function name in the same class. Function overloading is not allowed. Duplicate function names in different classes are allowed (not recommended). 

  • Once the action is mapped into Qualitia and used in a test case, do not change the existing signature or other details of the actions or the classes created. The functionality of the action can be modified. Do not delete the custom actions or custom classes that are used in test cases.

  • If the custom action belongs to any object type (such as WebEdit, WebElement, and so forth), ensure you add the objectInfo data type parameter while developing the code of an action.

  • While mapping actions into Automation Studio, it is important to map the action using <package.class> hierarchy. 

  • Objects should be added under appropriate Qualitia classes while mapping custom actions into Qualitia Automation Studio

New Recommendations from Qualitia v8.0.0

Making a New Class for Recommendations

package <QASpackagename>; 

import com.qualitia.execution.ActionResponse; 
 import com.qualitia.execution.ApplicationLogger; 
 import com.qualitia.models.testcase.ExecutionResult; 
 import com.webdriverfw.Wrappers.General; 

 <QASimportlist> 

 

 public class <QASclassname> extends General { 

 

 //Define your customs actions here 

 

 }

Writing Custom Actions in the Accepted Format

   package <QASpackagename>; 

import com.qualitia.execution.ActionResponse;   import com.qualitia.execution.ApplicationLogger;   import com.qualitia.models.testcase.ExecutionResult;   import com.webdriverfw.Wrappers.General; 

  <QASimportlist> 

  

  public class <QASclassname> extends General { 

  

  //Define your customs actions here 

  

  }


 public ActionResponse <QASmethodname>(<QASparametername>) { 

     

     ActionResponse actionResponse = getActionResponse(); 

     ApplicationLogger applicationLogger = actionResponse.getApplicationLogger(); 

     actionResponse.setExecutionResult(ExecutionResult.FAILED); 

     try { 

               // Your code here... 

             

           applicationLogger.writeToInfoLog(""); 

           actionResponse.setMessage("Successful message"); 

           actionResponse.setExecutionResult(ExecutionResult.PASSED); 

        } catch (Exception ex) { 

           applicationLogger.writeToErrorLog("Exception message", ex); 

           actionResponse.setMessage(“Failed Message”, FailureCategory); 

           actionResponse.setExecutionResult(ExecutionResult.FAILED); 

        } 

        return actionResponse; 

}  

ApplicationLooger

  • applicationLogger.writeToInfoLog(""); 

  • applicationLogger.writeToErrorLog(""); 

  • Info Log

  • Error Log

Show Link of File in Info Log Section 

Setting an Execution Result

  • ExecutionResult.PASSED is used to set when the action is passed.

  • ExecutionResult.FAILED is used to set when the action is failed. 

  • ExecutionResult.DEFECT is used to set when the action has a defect. 

  • ExecutionResult.NOT_EXECUTED is used to set when the action halts the execution.  

In Older Versions before 8.0.0 :  

    public int EqualStrings(String a, String b)  

    {  

    if(a.equals(b))  

    {  

    DataLogger.writeToDebugAndInfoLogs("they are equal");  

    return 0;  

    }  

    else  

    {  

    DataLogger.writeToDebugAndInfoLogs("they are not equal");  

    return 1;  

    }  

    }  

  

    In Qualitia 8.0.0 Version :  

    public AcionResponse EqualStrings(String a, String b)  

    {  

    ActionResponse actionResponse = getActionResponse();  

    if(a.equals(b))  

    {  

    actionResponse.setMessage("they are equal");  

    actionResponse.setExecutionResult(ExecutionResult.PASSED);  

    return actionResponse;  

    }  

    else  

    {  

    actionResponse.setMessage("they are not                                                                                equal”,FailureCategories.Category.INVALID_DATA);  

    actionResponse.setExecutionResult(ExecutionResult.FAILED);  

    return actionResponse;  

    }  

    }

 Adding a Failure Category for a Custom Action

package com.webdriverfw.Wrappers; 

 Import com.qualitia.execution.failureclassifications.FailureClassificatio; 

 public enum MyCategoriesEnum implements FailureClassification { 

    MY_CUSTOM_CATEGORY1("This is my custom category 1"), 

    MY_CUSTOM_CATEGORY2("This is my custom category 2"); 

  

    private String name; 

  

    MyCategoriesEnum(String s) { 

        name = s; 

    } 

   public String getCategory() { 

        return name; 

    } 

}   

 


actionResponse.setMessage("message",FailureCategories.CustomCategory.NEW_CUSTOM_CATEGORY1);


actionResponse.setMessage("message",FailureCategory.newCategory("Categoryname")); 


package com.webdriverfw.Wrappers; 

 public class MyCategoriesConstants { 

   public static final String MY_CUSTOM_CATEGORY3 = "This is my custom category 1"; 

    public static final String MY_CUSTOM_CATEGORY4 = "This is my custom category 2"; 

} 


actionResponse.setMessage("message",FailureCategory.newCategory(MY_CUSTOM_CATEGORY3)); 

Qualitia Public APIs for Custom Actions


Debugging a Custom Action

  1. Do in the following order listed to create necessary test artifacts:

    1. Create a test case and include the custom action that you want to debug at the appropriate step. For more information, refer to /wiki/spaces/T2/pages/2681539278

    2. From the test case editor, click Run to dry run the test case to verify whether the custom action is hit.

    3. Create a test suite that contains the test case. For more information, refer to Creating a Suite.

    4. Create an offline suite using the test suite. For detailed instructions, refer to Creating an Offline Package.

  2. To add the required files for debugging the custom action:

    1. Open the custom action you want to debug in the Eclipse project.

    2. Add the TestHarness.Java file for the custom action in the Eclipse project.

    3. Add the Config Folder in the Eclipse project.

    4. In the config folder, open the startupSettings.json file, and specify the location of the offline suite for “SuitesDir”.
      For example: "SuitesDir":"D:/Qualitia Offline/Suite1"

  3. Insert a breakpoint at an appropriate line number in the custom action.

  4. Start debugging the TestHarness.Java file.

  5. The test suite execution starts.
    When the custom action is executed, the execution stops at the breakpoint you have inserted.
    You can go ahead and debug the custom action.

To specify Java system properties before executing the test suite.

  1. From the config folder in the custom action of Eclipse, open the QualitiaSystemProperties.json.

  2. In the QualitiaSystemProperties.json file, enter the key-value pairs in the following format:

    1. {"key1": "value1",

      "key2": "value2",

      .

      .

      "keyN": "valueN"}

  3. Save the file.   

Troubleshooting (Custom Action Module)

Import Custom Action Cannot be continue due to following errors;...

Resolution:

Updating Qualitia Project Path

Re-importing this java project is mandatory. Else, the user will not be able to access updated custom actions.  This is a one-time activity.

  1. Ensure you clone all the project data to the new directory.
    This includes Test cases, Tasks, Custom actions, and Java project folders (which hold all the latest custom action code).

  2. Remove the existing project from the workspace.

  3. To import the cloned java project from the new directory, right-click Package Explorer, and select Import from the context menu.

  4. On the Import window, under the General section, select Existing Projects into Workspace and then click Next.

  5. In the Select root directory section, click the Browse button, select <PROJECTNAME>_QASJavaproject and click Finish.
    This is in the new directory where you have cloned the Qualitia project data.

  6. Select General > Workspace > Select Refresh using native hooks or polling.

  7. Click Apply and Close.

Custom Action Custom Files are Not Pushed to Project Path GIT Repository

  1. Open the Eclipse Project.

  2. Click Windows > Preferences > Teams > Git > Projects.

  3. In the right side of the Preference dialog box, under Projects, deselect the Automatically ignore derived resources by adding them.gitignore checkbox.

Other Validations

Validation Error

Resolution

.classpath file is not present in your Eclipse project location 

Ensure that the Eclipse project was built successfully after adding all required artifacts (lib, bin, src folders) to it. This will create a .classpath file. 

.class files are not present in your Eclipse project location 

Collect the required compiled .class files and add them to the Eclipse project (under bin folder). Names of the required files is mentioned in the report.

Jar files mentioned in .classpath in your Eclipse project location

Collect all the required jar files and add them to your Eclipse project directory (under lib folder).

Java source files are not present in your Eclipse project location 

You need to generate the source code from the compiled class files and add them into the src folder under Eclipse project directory. For more information on the creating the source files, refer to the Importing Existing Custom Actions Created in Previous Qualitia Versions section. 

Once you have fixed all the errors mentioned above, you can continue importing custom actions in Qualitia. 

Modifying Custom Actions

Modify Custom Action Metadata

For custom actions that are added to a task or a test case, you can update only the Mandatory status of its parameters and no other metadata

  1. From the Expand Menu, click Develop.

  2. Click the Custom Actions tab.

  3. In the left pane, click the desired custom action which you want to update.
    Custom action details will appear in the right pane.

  4. Click Edit.

  5. Update Action Name, Description, Function Name, and parameters details based on the requirements.

  6. Click Save and Launch Editor.


    For desktop project custom action developed in VB, you cannot add or remove parameters from the mapped function for an unused cutsom action from Qualitia client.  To work around this issue, launch the associated VBS file from Qualitia client, add or remove parameters for the mapped function, and remap the function to the custom action from Custom Action window.


Modify Custom Action Code

Ensure that your associated role is assigned with Custom Actions privileges.

While editing, it is strongly recommended to view and edit custom actions code from Qualitia Automation Studio only. In case you want to edit multiple custom actions, you must launch the code for each action differently from the automation studio. Modifying multiple actions in a single go may put you in conflicting situations which are difficult to handle.

  1. From the Expand Menu, click Develop.

  2. Click the Custom Actions tab.

  3. In the left pane, select the desired custom action which you want to update.
    Custom action details will appear in the right pane.

  4. Click View Code.
    The code appears in the different section.

  5. To update the code in the Eclipse IDE, click Edit Code.
    The code template with an existing code opens in the Eclipse IDE.

  6. Update the code based on the requirements.

  7. Build the project and close Eclipse IDE.

    Once you close the Eclipse IDE, Qualitia automatically commits the code to the version control system like Bitbucket or SVN (if configured) and makes the code available to other Qualitia project members.



Deleting Custom Actions

Ensure that your associated role is assigned with the Custom Action Developer privilege.

  1. From the Expand Menu, click Develop.

  2. Click the Custom Actions tab.

  3. Search the desired custom action.

  4. Select the action in the left pane.
    Custom action details will appear in the right pane.

  5. Click Delete.

  • No labels