Chromium

You can use Chromium integration blocks in your workflows to start and control a headless web browser instance.

The Chromium integration provides a set of blocks that you can use to programmatically interact with a headless instance of a Google Chromium browser on a remote host. You can start a browser instance, navigate to a web page, then perform a range of page interaction tasks. For example, you can click fields and buttons, enter and submit text, drag elements, and upload files.

You might find this integration useful when you need to interact with systems that do not expose API endpoints and can be accessed only through web pages.

For example, you might need to upload several sizable files to a system, but can do so only through its web UI. In this scenario, you might build a workflow that uses Chromium blocks to automate this task. You might also, for example, build a workflow that crawls through web pages and scrapes their content automatically.

The Chromium integration uses the Puppeteer API. For more information, see Puppeteer.

Procedure

  1. Import the Chromium integration to your IBM® Concert Workflows® instance.
    1. Download the Chromium integration from IBM Automation Library.
    2. Import the downloaded integration to your instance. For more information, see Importing integrations.
  2. Set up a remote worker and enable the Puppeteer API add-on.
    • Optional: Install a remote worker and enable the Puppeteer add-on.
      • When you install or upgrade, include the --optional-addons=addon-puppeteer option when you run the install_rw.sh script.
    • Optional: If you already have a remote worker that runs in a Red Hat® OpenShift® or Kubernetes cluster, enable the Puppeteer add-on via either the remote worker installation script or the remote worker values file.
      To enable the add-on via the remote worker installation script, complete these steps:
      1. On the host where the remote worker runs, search for the install_rw.sh file and go to the folder that contains it.
      2. Append the --optional-addons=addon-puppeteer option to the options that you specified for this script when you installed the remote worker, then run the script again.
        For example, if you ran a command like this example when you installed the remote worker:
        ./install_rw.sh --license-acceptance=y --server-hostname=10.11.12.13 --worker-group-name=my-group --worker-group-secret-key=327fgs8d7dfdsf
        You can upgrade the remote worker to enable the Puppeteer add-on by running this command:
        ./install_rw.sh --license-acceptance=y --server-hostname=10.11.12.13 --worker-group-name=my-group --worker-group-secret-key=327fgs8d7dfdsf --optional-addons=addon-puppeteer
      To enable the add-on via the remote worker values file, complete these steps:
      1. On the host where the remote worker runs, search for the rna-rw-core-values.yaml file and go to the folder that contains it.
      2. Edit the file and uncomment the rna.addon_puppeteer section and the rna.addon_puppeteer.replicas attribute:
        imageRegistry: 423562884727.dkr.ecr.us-east-1.amazonaws.com
        rna:
          host:
          ...
          ...
          addon_puppeteer:
            replicas: 1
      3. Upgrade the Helm chart to enable the add-on by running this command:
        helm upgrade -n rna-core -f rna-rw-core-values.yaml rna-core ./RNA/images/rna-core
    • Optional: If you already have a remote worker that runs in Docker, enable the Puppeteer add-on.
      1. On the host where the remote worker runs, stop the remote worker by running this command:
        sudo docker compose -f ./pliant-worker/docker-compose.yml -p pliant-worker down
      2. Search for the docker-compose.yml file and edit it by using vi or a similar editor. For example:
        vi ./pliant-worker/docker-compose.yml
      3. Uncomment the addon_puppeteer section and its attributes, so that the file looks like this example:
        version: '2'
        
        services:
          pliant-worker:
            image: 423562884727.dkr.ecr.us-east-1.amazonaws.com/pliant-worker-nodejs-master:v1.138.0
            ...
          addon-ansible:
            image: 423562884727.dkr.ecr.us-east-1.amazonaws.com/addon-ansible-master:v1.47.0
            restart: unless-stopped
        
          addon-napalm:
            ...
            ...
        
          addon-pdf:
            ...
            ...
        
          addon-textfsm:
            ...
        
          addon-puppeteer:
            image: 423562884727.dkr.ecr.us-east-1.amazonaws.com/addon-textfsm-master:v1.19.0
            restart: unless-stopped
      4. Restart the remote worker by running this command:
        sudo docker compose -f ./pliant-worker/docker-compose.yml -p pliant-worker up -d
  3. On the host where IBM Concert Workflows® runs, in the sidebar, click Workflows.
  4. Create a workflow.
    1. Click + Create workflow.
    2. In the dialog, select the Hello, World template.
    3. Click Create. The workflow is opened in the editor.
  5. In the Start block, configure the required variables and settings.
    1. Create a variable of type number to store the ID of the page that is created when an instance of the headless browser is started.
    2. In the Worker Group dropdown, select the worker group that you attached the remote worker to when you installed the remote worker.
    3. Create any other variables that you need for your workflow scenario. For example, you might create variables that store browser content that you want to retrieve or upload.
  6. In the integration list, search for Chromium, then go to the Browser subfolder.
  7. Locate the New Page block and place it directly after the Start block in your workflow.
    Note: The New Page block starts a browser instance in the remote worker and returns the ID of the browser page. You need this ID for every subsequent operation that you want to perform in the browser.
  8. In the Assign block, assign the result of the New Page block to the variable that you created in step 5a.
    For example, if you created a variable called $pageId, complete these steps in the Assign block:
    • Set the variable field to $pageId.
    • Set the value field to $New_Page.result.
  9. In the integration list, go to the Chromium > Page subfolder.
  10. Locate the Navigate block and place it directly after the Assign block in your workflow.
  11. In the Navigate block, enter the information that enables the browser to access a web page.
    • In the pageId parameter, enter the name of the variable that you created in step 5a.
    • In the url parameter, enter the URL of the page that you want the browser to access.
  12. In the integration list, locate and add the Chromium blocks that you need to fulfill your workflow goal.
    • In each Chromium block that you add, set the pageId parameter value to the name of the browser tab ID variable that you created in the Start block.
    • To see detailed information about each Chromium block’s parameters, hover your mouse over them.
  13. Run, refine, and save your workflow.