Java connector methods
Summarize
Summary of Java Connector Methods Creating Integrations with Applications
The Java connector enables integration with Java applications by exposing methods at the connector, screen, and element levels. These methods facilitate various operations such as starting applications, retrieving window handles, and interacting with UI elements. Understanding these methods allows ServiceNow customers to automate and streamline their workflows with Java applications effectively.
Show less
Key Features
- Connector Level Methods:
- Start: Initiates the Java application. Mandatory parameters include the path to the application.
- GetMainWindowHandle: Retrieves the window handle of the launched application.
- CloseMainWindow: Closes the main application window.
- Terminate: Forces termination of the application.
- Screen Level Methods:
- GetFields: Extracts data from configured text fields in the application.
- Maximize/Minimize: Adjusts the application window size.
- MouseAction: Performs mouse actions like clicks on the application.
- SendKeys: Sends keyboard inputs to the active field.
- Element Level Methods:
- GetText: Retrieves text from specified text box elements.
- MouseClick: Executes a left-click on the targeted element.
- SetPassword: Securely inputs a password in password fields.
Key Outcomes
By utilizing the Java connector methods, ServiceNow customers can automate interactions with Java applications, improving efficiency and reducing manual input errors. Customers can expect to seamlessly start applications, capture data, perform actions within the UI, and manage application states, all of which contribute to enhanced operational workflows and user experience.
The Java connector exposes methods at the connector, screen, and element levels. While all types of elements have common methods, they also have different methods.
Connector level methods
Start
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Path | Path to the Java application in the local drive. | Data in | String | None | Yes | |
| Args | Arguments for the path. | Data in | String | None | No |
GetMainWindowHandle
Returns the window handle of the Java application launched by the Start method.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the Window handle of the application. | Data out | Integer | None | Not applicable |
GetMainWindowTitle
Returns the title of the Java application window.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the title of the window of the application. | Data out | String | None | Not applicable |
CloseMainWindow
Closes the main Java application window.
Terminate
Terminates the main Java application window.
Screen level methods
Close
Closes the active Java application window.
Focus
If the Java application window is minimized or running in the background, the method restores the focus.
GetFields
- Configure the Java connector and capture one or more text fields.
- Expose the screen level methods. See Use connector method.
- From the Object Explorer pane, drag the GetFields method to the design surface.
- Click the method settings icon (
).
- Select one or more text fields.
- Update the data type of the text field.
- To close the CHOOSE FORM ELEMENTS window, click OK.
A Data Out port is created for each text field you select.
The GetFields method can now return the data contained in the text fields.
GetInstanceCount
Returns the total number of instances of the Java application open.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the total number of instances of the Java application open. | Data out | Integer | None | Not applicable |
GetScreenShot
Captures and returns the screenshot of the Java application screen.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the screenshot of the Java application screen. | Data out | Bitmap | None | Not applicable |
GetWindowHandle
Returns the Windows handle number of the Java application screen window.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the Windows handle number of the Java application screen window. | Data out | Integer | None | Not applicable |
IsCreated
Returns the Boolean response based on whether the rules for a configured window match. When you configure a Java application screen, the MATCH RULES section of the Java connector window shows certain rules that match the screen configured. The method matches the same rules.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| MatchAllChildren | Returns the Boolean response after matching the rules of the elements of the screen. | Data in | Boolean | None | No | This parameter is relevant if you capture one or more elements. |
| Return | Returns the Boolean response to whether the rules of the Java application screen you configured matched. | Data out | Boolean | Null | Not applicable |
Maximize
Maximizes the Java application window.
Minimize
Minimizes the Java application window.
MouseAction
Performs different mouse device actions on the Java application such as left-click, right-click, and middle-click.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Action | Specifies the mouse device action. | Data in | Mouse device input | None | Yes | |
| ClickMiddle | Whether a middle-click will be performed. | Data in | Boolean | None | No |
Resize
Changes the width, height, and the position of the Java application window along the X and Y axis.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| xPos | Position of the window on the screen along the X-axis. | Data in | Integer | None | No | |
| yPos | Position of the window on the screen along the Y-axis. | Data in | Integer | None | No | |
| Width | Width of the window. | Data in | Integer | None | No | |
| Height | Height of the window. | Data in | Integer | None | No |
Restore
Restores the original dimensions of the Java application window. You can use the method after you have executed methods like Maximize and Minimize.
SendKeys
Send any data or keyboard input to the active field on the Java application. For example, you can send a string data "RPA" or a keyboard input [Space] to deselect a check box.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Keys | Sends the data or keyboard input to the active field. | Data in | String | None | Yes | |
| ClearExistingValue | Before sending any data or keyboard input, clears any existing value in the active field. | Data in | Boolean | None | No | |
| TypeDelay | Sets a delay before sending any data or keyboard input to the active field. | Data in | Integer | None | No |
SetFields
Set custom text in the text field elements captured from the Java application screen.
- From the Object Explorer, drag the SetFields method to the design surface.
- Click the method settings icon (
).
- Select one or more text fields.
- Update the data type of the text field.
- Click OK.
A Data In port is created for each text field you select. You can pass the string to set in the fields of the Java application.
To provide inputs to the parameters, see Configure port properties.
WaitForCreate
Each screen you configure in the Java connector is identified by some rules, displayed under the MATCH RULES section of the Java Connector window. The method returns a Boolean response based on whether the rules of the screen you had configured matches.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| timeoutinSeconds | Time after which the operation of the method times out. | Data in | Integer | None | No | |
| MatchAllChildren | Returns the Boolean response after matching the rules of the elements of the screen. | Data in | Boolean | None | No | |
| Return | Returns the Boolean response to whether the rules of the Java application screen you configured matched. | Data out | Boolean | None | No |
Element level methods
GetAccessibleActions
Returns the list of actions that you can perform on an element. For example, for a button, it returns Click.| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the list of actions that you can perform on an element. | Data out | List | None | Not applicable |
GetInstanceCount
Returns the total count of an element type in the Java application. For example, if there are three text boxes in an application, the instance count is 3.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the instance count of an element type in the application. | Data out | Integer | None | Not applicable |
GetText
Returns the text from the captured text box element in the Java application. To capture multiple texts from multiple text boxes, you must configure multiple text box elements.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Text | Returns the text contained in the text box of the Java application. | Data out | String | None | Not applicable |
IsCreated
Returns the Boolean response depending on whether the rules of the element you had configured match.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the Boolean response depending on whether the rules of the element you had configured match. | Data out | Boolean | null | Not applicable |
MouseClick
Performs a left mouse-click on the captured element.
PerformAction
Performs the specified action on an element. For example, click on a button. Each element allows a set of actions that you can get by executing the GetAccessibleActions method.
To provide inputs to the parameters, see Configure port properties.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Action | Accepts the action to be performed on the element. | Data in | String | None | Yes | You must specify the action exactly in the format as given by the GetAccessibleActions method. |
| Return | Returns True if the action was performed, else, False. | Data out | Boolean | None | Not applicable |
SetPassword
Automate entering password securely in the password field of a Java application.
| Parameter | Description | Data Port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Password | Accepts the password as a secured string. | Data In | Secured string | None | Yes | Since it accepts the password as a secured string, it only shows the length of the string when you right-click on the parameter and then click Preview Data. |
| UseSendKeys | SendKeys is a method used to send keyboard inputs such as characters, numbers, and symbols to text boxes inside an application. | Data In | Boolean | False | Yes | Tip: If the SetPassword method fails to input the password in the password field, set the value to True and execute the method again. |