Controlling Individual Entities

The first step in controlling applications is to control individual entities: items, pages and applications.

To control an entity, the following conditions must be satisfied:

  • The entity has been declared in the project

  • Desktop Agent is running

  • The entity is recognized by Desktop Agent

Controlling an Item

Basic Use Cases

In your projects, most control actions are performed on items. You usually perform control actions on simple items such as:

  • Fill or read an entry field

  • Click a button

The following methods allow these simple actions to be performed:

Simple Control Actions

click

Click an item (such as a button or link)

myAppli.myPage.myButton.click();

get

Read the value of an item

var value = myAppli.myPage.myField.get();

set

Set the value of an item

myAppli.myPage.myField.set(myValue);

check

Check an item (a radio button or checkbox)

myAppli.myPage.myField.check(true);

clickDouble

Double-click an item

myAppli.myPage.myField.clickDouble();

setFocus

Set focus on an item

 

Test Status of an Item

exist

Test existence of an item

var bExist = myAppli.myPage.myField.exist();

isEnabled

Check if item is enabled

isVisible

Check if item is visible

For a complete list of ctx.item class members, see the Desktop SDK Reference Guide.

Managing Control Errors

Before implementing control actions in the project scripts, it is advisable to test the controlling of individual items using the Tester view in the Debugger. The following actions are very helpful to script developers:

  • Clicking a field

  • Setting the value of a field

If the controlled item doesn’t respond as expected, check whether the controlling method returns an error.

Additional Features By Technology

The previous control actions are available in all application implementation technologies.

According to the application implementation technology (such as Windows or Web), item instances can implement additional features:

For a complete list of ctx.item class members, see the Desktop SDK Reference Guide.

Controlling a Multiple Item

Multiple items are controlled in the same way as non-multiple ones are. You must simply specify the index of the item’s instance using the i method:

If an item is multiple (see ‘Recognition’), you must specify one index via the Occurs level:

Get the instances count of a multiple item

You can get the count of different instances of a multiple item using the nbOccurs property:

For multiple items, you can only get the count of the last Occurs level:

Manage in one call the values of all instances of a multiple item

You can manage in one call the values of all instances of a multiple item using the following methods:

getAll

Get in one call the values of all instances of a multiple Item

setAll

Set item values in multidimensional objects, from an array object

getCol

Get the items of a given column in a two-dimensional array

getRow

Get the items of a given row in a two-dimensional array

Controlling Complex Items

Controlling complex items (such as a list or tree) can be more complex than controlling simple items.

First of all, try to control such items by using simple methods:

get

Read the selected value of a tree view or list view

set

Select a value in a tree view or list view

getList

Get the list of values of a tree view or list view

select

Select or deselect a value in a tree view

selected

Get the selected value for a tree view or list view

If the simple method doesn’t work as expected, there may be another way to control the targeted item, specific to the connector used to control the application. Please look at the documentation on the corresponding connector:

  • Controlling Complex Items Using the Web Connector

  • Controlling a complex Item using the UI Automation Connector

  • Controlling a complex Item using Java connector

  • Controlling a complex Item using Windows connector

  • Controlling a complex Item using HLLAPI connector

If you can't find a way to control your item, it may be due to the implementation of the application being controlled.

Advanced Use Cases for Controlling Items

Control an Item with Keystrokes

The recommended way to set the value of an item is to use the set method.

In some cases, this method doesn’t set the item value correctly. This may be because control actions are performed at a low level instead of at the user level.

In these cases, you can try setting the item’s value at the user level by:

  • Activating the page using the activate method

  • Setting the input focus on the item using the setFocus method

  • Setting the item’s value by sending keystrokes using the ctx.keyStroke method

This way, you exactly mimic the user action.

The drawbacks of this method are as follows:

  • The application cannot be controlled in the background

  • The user must not change the input focus during controlling

Control an Item with Mouse-Clicks

The recommended method to click an item is to use the click method.

In some cases, this method doesn’t do the action as required. This may be because control actions are performed at low level instead of the user level.

In these cases, you can try to click the item at the user level by:

  • Activating the page using the activate method

  • Clicking the item using the mouse, using the click method

This way, you exactly mimic the user action.

The drawbacks of this method are as follows:

  • The application cannot be controlled in the background

  • The user must not move the mouse during controlling

Retrieve the Content of an Item Using the Clipboard

If you cannot read the content of an entryfield by using the standard get method , you can try reading it using the clipboard:

  • Set the focus in the field

  • Select all the content by sending CTRL + A shortcut

  • Copy the content by sending CTRL + C shortcut,

  • Get the content of the clipboard using the ctx.clipboard.get method .

Retrieve the Index of a Clicked Multiple Object

You may have to track an event (such as CLICK ) on a set of multiple objects. For details on how to declare these objects correctly, see Declaration Principles.

If you need to know which element has been clicked, you can retrieve this information thanks to the event parameter ev.itemIndex.

Controlling a Page

Background

Most of the time, you do not need to perform control actions on pages. For example, there is no controlling method to open a page. Instead, you execute the control sequence described in the Functional Specification of the project. For example, click the Open button.

Basic Use Cases

However, the ctx.page class implements the following basic methods:

Simple Control Actions

activate

Activate a page

close

Close a page

Test status of the Page

exist

Test existence of a page

isEnabled

Gets enabled or disabled state of the page

isModal

Gets the ‘modal’ state of the page

isVisible

Checks if page is visible

Change the Page window state

maximize

Maximizes the page

minimize

Minimizes the page

restore

Restores the page

setVisible

Shows or hides the page (or an element of the Web browser )

getTitle

Gets the page title

Send a sequence of keys

keyStroke

Sends a sequence of keys to the page

keyStroke2

Sends a sequence of keys to the page (alternative method compared to ctx.item.keyStroke)

Manage all items of a page

getItems

Gets all the item values in the page

setItems

Sets all the item values in the page, from a data object

Additional Features By Technology

Depending on the application implementation technology (such as Windows, Web, or, Java), thectx.page class implements additional features:

Advanced Use Cases for Controlling Pages

Manage Page Instances

count

Returns the number of page instances for a given application real instance

Get an Item by its name

If necessary, you can get an item by its name using the getItem method, instead of using the item object.

getItem

Gets an item by its name

is equivalent to

Controlling an Application

Basic Use Cases

Most of the time, we do not perform control actions on applications. However, the ctx.application class implements the following basic methods:

exist

Tests application existence

For a complete list of ctx.application class members, see the Desktop SDK Reference Guide.

Additional Application Controlling Features By Technology

Depending on the application implementation technology (such as Windows or Web), the ctx.application class implements additional features:

Advanced Use Cases for Controlling Applications

Start an Application

With some technologies (such as WEB and WIN.), you can start a declared application by script, using the start method:

By default, this method uses the application's path registered when the application was captured:
  • The EXE file path for desktop applications

  • The URL for Web applications

This issue can be managed by providing the right path in the start method:

An alternative to set the application's path for each environment using the setPath method:

Manage Application Instances

For details on this topic, see Multi-Instance Management.

count

Returns the number of application instances

setDefaultInst

Memorizes the default instance for the application

Manage the Current Page

currentPage

Current Page

Gets a Page by its Name

If necessary, you can get a page by its name using the following method, instead of using the page object.

getPage

Gets a page by its name

is equivalent to