Call a JavaScript function action

The Call a JavaScript function action in the Browser package enables you to call an existing JavaScript function directly in a webpage or in an iFrame within a webpage. This action also allows you to call a JavaScript function in desktop Chromium Embedded Framework (CEF) applications.

Configure the settings

Note:
  • For macOS platform, this action supports Google Chrome and Safari browsers.
  • For Windows platform, this action supports Google Chrome and Chromium-based Microsoft Edge browsers.
  • This action supports CEF-based desktop applications.
  1. Select the browser tab from the list of active supported browser tabs or insert a window variable. To call a JavaScript function in CEF applications, use the Application tab. From the Application tab, select the specific CEF application from the list of applications. A CEF application integrates web browser functionality by embedding Chromium into a desktop application.
    Important:
    • To automate desktop applications that use CEF framework, you must develop and run your automations in elevated mode. See Automate applications running as an admin user.
    • To automate CEF applications, ensure you use the Browser package version 3.13.1 and later.
    Note:
    • Automating cross domain iFrame in CEF applications is not supported.
    • CEF applications will not be listed under the Browser tab.

    正規表現 (regex) を使用して、ウィンドウ タイトルを識別できます。正規表現の条件として [文字列] または [パターン] を選択し、値を入力します。デフォルトでは、[ウィンドウ タイトル] フィールドで大文字と小文字が区別されます。

    ブラウザのタイトルを識別する場合、[大文字と小文字が区別される] オプションを有効にすると、大文字と小文字を一致させることができます。このオプションを無効にすると、大文字と小文字が一致しないウィンドウ タイトルを識別できます。
    Note: システムにインストールされている最小 Bot Agent バージョンが、Automation 360 v.26 でリリースされたバージョンであることを確認してください。Automation 360 v.25 以前でリリースされた Bot Agent バージョンを使用している場合、ウィンドウ タイトルはデフォルトで大文字小文字を区別して識別されます。
    たとえば、単語の後に「- Notepad」が続くすべてのウィンドウ タイトル名に一致させるには、[文字列] 値として「* -Notepad」と入力するか、[パターン] 値として ((\w)\s)*document-Notepad を使用してこのパターンにマッチするウィンドウ タイトルのみに一致させます。
    Note:
    • 任意のactionでウィンドウ タイトルの入力値として「-title」を含む [文字列] 型の正規表現を使用する場合、bot にランタイム エラーが発生する可能性があります。ランタイム エラーを防ぐために、「*-title」と文字列を追加入力したときに特定のタイトルのアプリケーションが開くことを確認します。アスタリスク (*) は単なる文字であり、ワイルド カード文字ではありません。
    • 任意のactionでウィンドウ タイトルの入力値として「-title」を含む [パターン] 型の正規表現を使用する場合、入力値「*-title」が正しくないため、bot にランタイム エラーが発生する可能性があります。

      有効な正規表現パターンを使用していることを確認してください。

  2. Optional: Use the Capture object option to capture the iFrames.
    Note: You can use the Capture object feature to call and run an existing JavaScript function inside an iFrame.
  3. In the Function name field, specify the name of the existing JavaScript function that you want to call.
  4. Optional: In the Arguments section, click Add argument to add arguments that must be passed to call the JavaScript function.
    1. In the Argument details dialog box, select the Argument type required for the specific argument.
    2. In the value field, enter the corresponding value or variable of the selected type that you want to pass.
      Note: All string values in arguments are passed as is without any character being converted or escaped.
  5. Optional: In the Time out after field, enter the number of seconds the bot must wait for the browser action to complete.
    Note: Enter a timeout value of at least 9 seconds.
  6. In the Return Type field, select the type of value returned by the JavaScript function.
    Note: If the function does not return anything, in the Return Type field, select None.
  7. For any Return type except None, in the Save the outcome to a variable field, select a variable for selected Return type to hold the JavaScript function output.

Create variable

To create a variable for selected Return type, perform the following steps:
  1. Click the Create variable symbol next to the Save the outcome to a variable field.

    A Create variable dialog opens with default variable name for the type of variable selected.

  2. Optional: Specify the variable information in the Description field.
  3. Optional: Specify a value in the Default value field.
  4. Click Create & select to select the newly created variable.

Supported JavaScript types in Argument and Return type fields

The following JavaScript types are supported:

  • String, Number, and Boolean JavaScript types which correspond to the same variable types in bot variables.
  • Array JavaScript type which corresponds to the List variable type in bot variables.
  • Object JavaScript type which corresponds to the Dictionary variable type in bot variables.