Skip to content

JavaScript

The JavaScript component enables userto insert a JavaScript into a webpage. Using this component, user can manipulate the browser Document Object Model (DOM), read HTML tags or set HTML tags. JavaScript component is useful while working with custom HTML controls, where standard Intellibot components such as GetText, SetText, GetTable, etc. fail to achieve the desired result.

Screenshot

Supported Functions

Double Click on the JavaScript component title bar to launch the JavaScript Editor Window.

Screenshot

  1. Parameter section allows users to create input variables (by clicking on Screenshot the icon) and use them in the JavaScript. Once a parameter is created, it can be renamed, and its data type can be changed. For each parameter that is created, JavaScript component will expose a Data In port.

  2. JavaScript section is where the JavaScript is entered.

  3. In the Return Type section, Users can define the return data type.

Ports

The JavaScript component exposes Control In and Control Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Can be connected to the Control In port of another component, or the default end component.
Data In Data In ports are dynamically created by double clicking on the JavaScript component title bar and clicking on the Screenshot icon.
Data Out Provides the data returned by the JavaScript return statement. Return statement is essential for the component to read the output of the JavaScript entered.

Properties

The JavaScript component exposes the following properties.

Property Description
Search Search for the respective property.
Delay After Execution Specifies the wait time (in seconds) after the actions is executed.
Delay Before Execution Specifies the wait time (in seconds) before the actions is executed.
Name Specifies the name to identify the component.Set the name to match the application field the user is interacting with.
Click X Specifies the location of the JavaScript action on the X-axis.
Click Y Specifies the location of the JavaScript action on the Y-axis.
Search As A Gray Scale Image Defines the selected area as a gray scale image.
Threshold Specifies the image matching accuracy before performing the click operation.Value of 1 defines 100% match, 0.5 defines 50% match; Defaults value is 0.9 or 90% match.
Max Wait Time in Seconds Defines the number of Seconds to wait for the image/application to appear on the screen. Default value is 30 Seconds.
Wait After Image Found Specifies the wait time (in seconds) after the image is found.
Wait For Create Defines if the JavaScript component must wait for the image to appear on the screen. Default value is True.

Example

Let us take an example of using the JavaScript component to extract the HTML table from a web page.

Screenshot

To use the JavaScript component:

  1. In the Toolbox drag and drop the StartApp component on to the Design Surface.

  2. Double click on the File Path port of the Start App component and enter the below URL

    https://intellibot.io/

  3. In the Toolbox, expand Actions (UI).

  4. Drag the JavaScript component and drop it on the Design surface.

  5. To select the region, click Screenshot.

    Then Press “CTRL+SHIFT” for selection message is displayed.

  6. Press CTRL+SHIFT.
    The mouse pointer becomes a crosshair.

  7. Select an area within the webpage where you want the JavaScript to be inserted.
    The selected region is displayed in the JavaScript component.

  8. Double click on the JavaScript component title bar to open the JavaScript Editor window.

  9. Then write the JavaScript for the particular operation (In this example the javascript is written to get the text from browser)

    Screenshot

    Note

    You can write simple or complex JavaScripts to interact with the browser DOM. Similar to the JavaScripts used within a web page.

  10. Drag and drop the Show component on the design surface to display the extracted text from browser.

  11. Connect:

    • The Control ports between Start and the StartApp component.

    • The Control Out port of the StartApp component with the Control In port of the next JavaScript component.

    • The Control Out and Data Out port of the JavaScript component with the Control In and Data In port of the MessageBox Show component.

  12. Click Run.

    Screenshot