Using Custom Actions

Modified on Fri, 26 Apr 2024 at 06:26 PM

Custom Action Overview 

Custom action is needed when you want to extend the functionality of your automation framework beyond what default actions provide. Automation engineers and developers can write custom actions for incorporating any application specific requirements.


You can create custom actions in algoQA to simplify complex processes. For example, you can merge multiple steps into a single action, such as logging in with just one step instead of entering a username, password, and clicking the login button separately.

Custom actions provide flexibility to extend the functionality of algoQA. You can import your existing methods into algoQA and use them as custom actions to enhance your automation capabilities.


Creating  a Custom Action

Perform the following:

  1. On the Main Canvas, navigate to the required project under Project Explorer pane and select More Menu > Code Editor screen as shown:

  2. Custom Setting Editor screen appears. In this screen, click to create a new custom action file.

    Enter the name with the appropriate file extension, then click the tick mark icon to save the changes. The custom action files will be saved under the Utility folder, and you can also create subfolders if needed.


    As a best practice it is recommended to follow coding guidelines while creating custom actions for the chosen programming language.

  3. You can create a new custom action and if needed, refer to the Code Snippet pane for assistance.  Click the icon to copy the code and paste it into your required file.

    Following are the listed custom actions in the Code Snippet pane.
    • click 
    • enter text
    • verify displayed
    • double click
    • use current driver
    • get value from test data
    • clear text
    • loop multiple elements
    • get text
    • crawler
    • API merged steps

  4. In the configuration step for a custom action, you can use the following basic structure for the chosen language, such as Java:

    Java basic structure code snippet


Leveraging Custom Actions

Leveraging algoQA workflow you can add custom actions in Node Configuration, Follow Me and Edit Scenarios features and functionalities.

Node Configuration


While configuring nodes, you can perform the following:

Updating Custom Action
While configuring nodes, you can update the custom action.  Navigate to the  Control  List Panel  window and update the default method with the custom action that you have created, as shown in the following screenshot: 


Configuring custom action
Perform the following: 

  1. Navigate to the Test Case generated folder > More Menu  > Custom Setting Editor > Code Editor screen. 
  2. In this screen, select Configuration button. 
  3. In the Configuration Settings window:
    • Add the appropriate Automation Type by selecting the arrow.
    • Add custom action file name. 
    • Map the existing custom action by providing the following details, as shown :
      Following is an example of Java basic structure code used in configuring a custom action step:
      
      class CustomUtility {

      public void SimplifyWorkflow() {
      // Custom action code
      }


      } In this example,  <file name> is replaced with CustomUtility and <method name> with SimplifyWorkflow when creating a custom action.


      Functionality Summary
       
      Field
      Description
      Custom Action 
      This action is called in the Edit Object Repository File or where ever you are configuring the action.
      Method 

      This method will be called wherever <custom action>has been configured during the profiling of the application and Mapping method will be implemented in generated scripts. 



      • Click Submit. You can see the custom action in your generated Feature File.
      • You can add custom actions in a configuration file using different methods. Following are the ways to add custom actions in a configuration file.
        • You can reuse the custom actions for dynamic Xpaths.

          When configuring a custom utility method for dynamic XPaths, use the following configuration code:

          Config: action-<custom action> : method : <file name>.<method name>(object)
          
          In this code, object is the mandatory keyword . Ensure not to replace it.
          
          
        • If you wish to pass parameters to the same code, then use the following configuration code:
          Config: action-simplify workflow : method : custom utility. simplify workflow (object, param)
          
          In this code, parameter can be an argument.

        • If you wish to pass without any parameter or dynamic XPaths, use the following configuration code.
          Config: action-<custom action> : method : <file name>. <method name> ( )
          
        • If you wish to use an assertion, use the following configuration code:
          Config: action-<custom action> : method : <file name>. <method name> (assertion).
          In this code, custom action name must contain verify keyword.

        • If you wish to pass only parameters, use the following code:
          Config: action-simplify workflow : method : custom utility. simplify workflow (param)


Follow Me Feature 
Perform the following:

  1. You can record a scenario by clicking the Follow Me feature on the Main Canvas. Record Scenarios screen appears. In this screen, enter the scenario name and scenario outline.


  2. Click 'Create' to open the 'Create Profile Sequence' pop-up window. Select the corresponding feature to view the following screen. In this screen, choose the appropriate configured custom action from the drop-down list and click 'OK'.


Edit Scenarios

  1. On the Main Canvas, navigate to More Menu > Edit Scenarios. You can add a custom action in the Edit Scenario Form by editing the particular Given-When-Then step.
  2. Click Tick mark icon and Save the changes.


Importing custom actions

Navigate to the Test Case generated folder> More Menu > Custom Setting Editor > select + icon > Upload File option to import the existing custom methods.


Hiding a custom action

To hide a custom action in the Project Settings page:

In the Project Explorer pane, navigate to the appropriate Test Case generated folder > select More Menu >Settings option to access Project Settings Page. In this page, choose the Hide Custom Action checkbox.

Alternatively, you can access Project Settings page by navigating to the Main Canvas and clicking the icon.




















Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article