Dynamic applications
A dynamic application is like a regular application but it is defined and instantiated during the execution of a flow. It can be used to create cross-application flows in a more fluid manner than having to define regular applications and using Flow.run to execute parts of the overall flow. Dynamically created applications are attached to or launched on-the-fly.
The Application constructor takes two arguments. The first argument is the application configuration. It can be either a string in which case we will;
- try to find an existing application with the same identifier or name and use its configuration, or
- construct a
NATIVEapp configuration with atitleBarContainsmatch based on the argument.
So if you have a “Notepad” application, the example above will use that configuration, if not then it will try to find a window that contains the text “Notepad” in the titlebar and attach to that window as a native application.
If you provide an object to the constructor it will be used as the configuration for the application. In that case the following properties are supported (the same ones you use in Cuesta to configure an app):
typethe type of the application (see ApplicationTypes for a list of pre-defined types)launchWiththe command or url used to launch the applicationlaunchWithArgumentsthe arguments given to the process when launchinglaunchWithFlowIdthe id of the flow to be used to launch the application (this flow must spin up the application)launchTimeoutin secondsworkingDirectorythe working directory to set for the application when launchingtitleBarContainsa regex to match the titlebar when attachingframeContainsa regex to match the frame-type when attachingprocessContainsa regex to match the process name when attachingexecutablePathContainsa regex to match the path to the executable when attachingurlContainsa regex to match the url when attaching (for web-based applications)jvmLocationan alternative location to look for a JVM (if Java app)openInselect between “window”, “tab”, “app” and “incognito” for browsers that support these modesswitchesextra switches for embedded Chrome browserpopupHandlinguse “PopupShowInInternalWindow” to use an alternative popup-handling for embedded browserskillOnDetachclose the embedded browser once the flow ends (defaults totrue)
Most properties are optional, however you need launchWith to be able to launch an application. Only mandatory options are type and at least one of the *Contains properties.
Attach to an existing notepad window:
var notepad = new Application({
titleBarContains: "Notepad",
type: ApplicationTypes.NATIVE
});If no existing “Notepad” instance is running we might want to be able to launch a new instance:
var notepad = new Application({
launchWith: "notepad.exe",
titleBarContains: "Notepad",
type: ApplicationTypes.NATIVE
});The second argument contains configuration options for the behaviour of the Application, it can hold the following properties:
noImmediateLaunchOrAttachmeans that we don’t automatically attach/launch the application - you then have to invoke thelaunchOrAttachmethod on the application instance to actually interact with the application.noLaunchdisables the launch functionality s.t. the application must be running already
Application methods
Create a field
For convenience you can invoke the newField(...) function on the Application instance instead of creating new Fields using their own constructor.
var notepad = new Application("Notepad");
var contentField = notepad.newField("**/(name)RichEdit Control");
// is equivalent to
contentField = new Field("**/(name)RichEdit Control", notepad);Then you can interact with the field as any normal field invoking .click(...), .inspect(...) etc.
Launch and/or attach
The launchOrAttach function will attach (if it can find a matching application) or launch the application. It can be invoked if you have set the noImmediateLaunchOrAttach to true when you created the application.
App methods
The Application instance contains approximately (no session()) the same set of methods as on the global App instance. This means you can read the title(), exit() the application, navigate(...) to other urls if the application is browser-based and so on.
Application types
A list of predefined application types to use in a dynamic app. The following are available:
ApplicationTypes.JAVA;
ApplicationTypes.NATIVE;
ApplicationTypes.CHROME;
ApplicationTypes.FIREFOX;
ApplicationTypes.EDGE;
ApplicationTypes.IE;
ApplicationTypes.EMBEDDED_CHROME;
ApplicationTypes.EMBEDDED_IE;
ApplicationTypes.PROXIED_IE;