VMware Aria

 View Only
  • 1.  Is There a Way to Detect if the JavaScript is Executing in Aria Automation?

    Posted Aug 22, 2023 01:37 PM

    The JavaScript Rhino engine can be used outside the JavaScript runtime environment from Aria Automation. This allows us to create JavaScript source code independently from Aria Automation. However, due to the different environments, it may be necessary to distinguish whether the source code is executed in Aria Automation or not. Does anyone know of a way to detect if the source code is executing in Aria Automation or not. Maybe by querying an environment variable? Or the query of an attribute?

    Thanks for hints and tips.
    Best regards
    Stefan



  • 2.  RE: Is There a Way to Detect if the JavaScript is Executing in Aria Automation?

    Posted Aug 23, 2023 07:07 PM

    What if you check whether System object exists?



  • 3.  RE: Is There a Way to Detect if the JavaScript is Executing in Aria Automation?

    Posted Aug 24, 2023 11:58 AM

    Hello ,

    thank you for your suggestion.

    But I use a simulation of the System object in my coding outside of the JavaScript runtime environment from Aria Automation. That's why I had thought of an environment variable, for example.

    Best regards
    Stefan



  • 4.  RE: Is There a Way to Detect if the JavaScript is Executing in Aria Automation?

    Posted Aug 24, 2023 07:06 PM

    some rarely used methods you do not plan to mock, i.e. Server.getAllPluginInfo() ?



  • 5.  RE: Is There a Way to Detect if the JavaScript is Executing in Aria Automation?

    Posted Aug 25, 2023 12:10 PM

    Hello  ,

    this is a good idea, thank you for your suggestion.

    Best regards
    Stefan



  • 6.  RE: Is There a Way to Detect if the JavaScript is Executing in Aria Automation?
    Best Answer

    Posted Aug 27, 2023 07:08 AM
    Edited by Stefan Schnell May 07, 2024 12:38 AM

    The setting of environment variables in the context of Aria Automation is very interesting. When the command printenv is entered in a terminal window, many fewer environment variables are displayed than when the same command is executed in an action.

    var command = new Command("printenv");
    command.execute(true);
    var commandOutput = command.output;
    System.log(commandOutput);

    When I executed the above code, many environment variables were displayed that were specific to Aria Automation. Here a selection:

    /**
     * ABX_SERVICE_PORT
     * ABX_SERVICE_SERVICE_HOST
     * ORCHESTRATION_UI_PORT
     * ORCHESTRATION_UI_SERVICE_HOST
     * TENANT_MANAGEMENT_UI_PORT
     * TENANT_MANAGEMENT_UI_SERCICE_HOST
     * VCO_CONTROLCENTER_SERVICE_PORT
     * VCO_CONTROLCENTER_SERVICE_SERVICE_HOST
     * VCO_SERVICE_PORT
     * VCO_SERVICE_SERVICE_HOST
     */

    So I tested the following tiny snippet:

    var VcoControlcenterServicePort = java.lang.System.getenv("VCO_CONTROLCENTER_SERVICE_PORT");
    
    if (VcoControlcenterServicePort === null) {
      System.log("VcoControlcenterServicePort not set");
    } else {
      System.log(VcoControlcenterServicePort);
    }

    StefanSchnell_0-1693119288788.png

    It delivers in the context of Aria Automation a result, and in the context of a simulation null.

    StefanSchnell_1-1693119596252.png

    This seems to be a valid approach to differentiate whether a program is executed in the context of Aria Automation or not.

    However, the question now would be how stable are these environment variables? I have tried this with the Aria Automation version 8.5.1. Has anyone already experience with this?