Activities
latest
false
Inject Js Script - Other latest
Banner background image
logo
UI Automation Activities
Last updated Feb 26, 2024

Inject Js Script

UiPath.Core.Activities.NInjectJsScript

Description

Executes JavaScript code in the context of the web page corresponding to a UiElement.

This activity must be added inside a Use Application/Browser activity.

This activity is compatible with Object Repository.

Project compatibility

Windows - Legacy | Windows

Windows - Legacy, Windows configuration

Designer panel
  • Click Indicate in App/Browser to indicate the UI element to use as target.

    After you indicate the target, select the Menu button to access the following options:

    • Indicate target on screen - Indicate the target again.
    • Edit target - Open the selection mode to configure the target.
    • Remove informative screenshot - Remove the screenshot of the target application or web page.
    • Add to Object Repository - Add the current UI element to a library project, from where it can be reused throughout your automation process.
  • Script code - The JavaScript code you want to run. You can write it here as a string, or add the full path of a .js file which contains the code to be executed. It should contain a single anonymous function, as in the example below:
    function (element, input) {
        return "result";
    }function (element, input) {
        return "result";
    }
    where element represents the HTML element corresponding to the calling UI node, and input represents the input string provided by the caller.
  • InputParameter - Input data for the JavaScript code, as a string or string variable.
  • Save script output to - Where to save the result of the JavaScript code.
Properties panel

Common

  • Continue on error - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.
  • Delay after - Delay (in seconds) between the time this activity is completed and the time the next activity begins any operations. The default value is 0.3 seconds. Adding a delay between activities ensures that one activity has enough time to complete before the next activity begins.

  • Delay before - Delay (in seconds) between the time the previous activity is completed and the time this activity begins performing any operations. The default value is 0.2 seconds. Adding a delay between activities ensures that one activity has enough time to complete before the next activity begins.

  • Display name - The name displayed for the activity in the Designer panel. A display name is automatically generated when you indicate a target.

  • Timeout - Specify the amount of time (in seconds) to wait for the activity to be executed before throwing an error. You can also choose a predefined value from the drop-down menu: 10 (s), 20 (s), 30 (s). The default value is 30 seconds.

Input

  • Input parameter - See Input parameter in the Designer panel.
  • Script code - See Script code in the Designer panel.
  • Target - The target element. Target element must be set. Before indicating on screen, this field is set to (null). Once the target is indicated, all properties regarding the element that was indicated are displayed.
    • CV Control type - Indicates the type of control identified using Computer Vision.
    • CV Text - Indicates the text identified using Computer Vision.
    • Fuzzy selector - The parameters for the fuzzy selector.
    • Native text - The text that is used to identify the UI element.
    • Responsive websites - Enable responsive websites layout.
    • Strict selector - The strict selector generated for the UI element.
    • Targeting methods - The selector types that you want to use for identifying the element. This property can be set to any combination from the drop-down menu:
      • None
      • Strict selector
      • Fuzzy selector
      • Image
      • Native text
      • Computer Vision
    • Visibility check - Checks whether the UI element is visible or not. You can choose one of three options from the drop-down menu:
      • None - Does not check for visibility.
      • Interactive (for Fuzzy Selector) - Default option. Checks if the element is potentially visible, ignoring page scroll and obstructions by other apps, or the fact that the application is minimized. This check is useful when trying to ensure that you are not targeting invisible elements that exist in the DOM but are hidden.
      • Fully visible - Checks if the UI element is visible or not.
    • Wait for page load - Before performing the action, wait for the application to become ready to accept input. You can choose one of three options from the drop-down menu:
      • None - Does not wait for the target to be ready.
      • Interactive - Waits until only a part of the app is loaded.
      • Complete - Waits for the entire app to be loaded.
    • Window selector (Application instance) - The selector that is used for the application window. Only applicable when the window attach mode is set to Application instance.

Input/Output Element

  • Input element - The UI element on which the activity is executed, stored in an UIElement object. This field supports only UIElement objects. This object can be obtained from the Output Element property field of other UI Automation activities.
  • Output element - Outputs a target UI Element and stores it in a UIElement object, which can be further used to target the same element with other activities.

Misc

  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level. This field supports only Boolean (True, False) values. The default value is False.

Options

  • Execution world - The JavaScript environment for the script execution. Choose from the drop-down menu of one two options:
    • Isolated - Allows access to the HTML elements, but prevents access to page variables and code. Use this option to ensure that the script execution does not conflict with the page. This is the default selection.
    • Page - Allows access to the HTML elements, page variables, and code. Use this option if you need to access page variables (e.g., jQuery $) or to interact with page code (e.g., window.alert). Using this option is required to fix this known issue specific to MV3 extensions.

    You can change the Execution world property for all Inject Js Script activities through Project settings.

    Note: The Execution world option is available starting with UiPath.UIAutomation.Activities version 22.12.

Output

  • Script output - The string result returned from JavaScript code.
  • Description
  • Project compatibility
  • Windows - Legacy, Windows configuration
Support and Services icon
Get The Help You Need
UiPath Academy icon
Learning RPA - Automation Courses
UiPath Forum icon
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.