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
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);
}
It delivers in the context of Aria Automation a result, and in the context of a simulation null.
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?
What if you check whether System object exists?
Hello @xian_,
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
some rarely used methods you do not plan to mock, i.e. Server.getAllPluginInfo() ?
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);
}
It delivers in the context of Aria Automation a result, and in the context of a simulation null.
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?