Code-based development mode

Updated at:

This document describes the code-based development process. For more information, see Overview.

1. Create a project in code-based development mode

When you create a new project in the editor, select the Basic Code Project Template to create a project in code-based development mode. For more information about project development modes and saving methods, see Cloud and local projects.

2. Development interface

The code-based development interface consists of five main areas: the menu and shortcut buttons, the pane on the left (Components and Project), the central flow code editor, the control management pane on the right, and the bottom pane (Logs, Data View, and Parameters).

image

  1. Menu. Includes the following:

    1. File: Create, open, save, and close projects. The Exit button closes the editor.

    2. View: Show or hide panes. If you close a pane in the editor, you can reopen it from this menu.

    3. Project: Manage custom software development kits (SDKs) and third-party libraries in Component Management. You can import enterprise-specific SDKs or third-party libraries into the project. The Publish feature lets you publish the project as an application to the enterprise marketplace.

    4. Design: Activate the control capture tool.

  2. Toolbar. Provides shortcut buttons for actions such as creating, opening, saving, and closing a project, capturing controls, selecting a flow to start debugging from, managing components, and publishing.

  3. Components pane. Lists all available SDKs in a tree structure by purpose. When you select an SDK, its code hinting information appears below.

  4. Project pane: Manages the project structure. You can right-click to rename the project, open the project folder, create new folders to organize flows, and create new automation flows.

  5. Flow code editor. A built-in Python Integrated Development Environment (IDE) for writing Python code. The editor supports code hinting, which automatically displays available methods when you reference SDK components. You can set breakpoints in the line number area for flow debugging. Hover over a component to view its parameter details and usage instructions.

  6. Controls pane. Supports multiple ways to capture controls and provides a grouping feature. You can right-click a control to copy its name, edit it, or delete it. Use the settings button to select operations such as click and input.

  7. Logs pane. Displays logs generated during flow execution, such as system logs, operation logs, and debug logs.

  8. Data View. Supports writing data from an automated collection to a structured view in real time. It also lets you seamlessly import data from and export data to Excel for easy validation, analysis, and subsequent processing.

  9. Parameters pane. Defines the input parameters for the current flow.

3. Project structure

A code-based project contains three types of items:

  • Flows: Main flow and child flows.

    • main is the main flow. After you publish the project as an application, the entry point for calls is the start() method of the main flow.

    • Right-click in the Project pane to create a child flow. You can also create multi-level folders.

    • Flows can call each other.

  • References: Stores referenced third-party libraries and custom components.

    • These references are managed using the Component Management feature.

  • Resources: Stores resource files needed at runtime, such as Excel files.

4. Basic syntax

The code-based development mode must be compatible with the Python version displayed in the bottom-right corner of the editor.

Common syntax

  • Function definition: Use def to create reusable functions and improve code organization.

  • Module import: Use import to include standard libraries or third-party modules.

  • Flow control: for/while loops and if/elif/else conditional statements.

  • Exception handling: Use the try/except structure to catch and handle runtime errors.

  • String operations: Use "{}".format() to insert dynamic content, and use split()/join() to process text.

Common modules

Module

Purpose

Example scenario

os/sys

File system and process operations

Directory traversal, environment variable management

datetime

Date and time processing

Timestamp calculation, formatted output

json

Data serialization

API response parsing, configuration file processing

re

Regular expression

Text pattern matching, data cleaning

requests

HTTP requests

API calls

pandas/numpy

Data processing

Tabular data operations, numerical calculations

Variable naming suggestions

Use semantic naming. For example, order_total is better than ot. Use the is_ or has_ prefix for Boolean values, such as is_valid. Avoid single-letter variables, except for loop counters such as i. Follow the variable naming conventions to ensure code readability and efficient team collaboration.

5. Capture controls

A "control" is the basic object that a Robotic Process Automation (RPA) bot uses to simulate human interaction for interface automation. It represents various interface elements that are used when an application (flow) is executed. For example, an input box, a search button, a page title on a webpage, and a logon button on a client can all be considered controls. For more information, see Capture and use controls.

6. Use SDKs

More than 700 built-in automated Python methods are available. The common categories are listed in the following table:

Category

Purpose

Reference location

Related automation methods

Win32

Operate on window objects

rpa.ui.win32

Win32

Java

Operate on Java objects

rpa.ui.java

Java

IE

Operate on the IE browser

rpa.app.ie

IE

Chrome

Operate on the Chrome browser

rpa.app.chrome

Chrome

Edge

Operate on the Edge browser

rpa.app.edge

Edge

SE360

Operate on the 360 browser

rpa.app.se360

SE360

SAP

Operate on the SAP client

rpa.app.sap

SAP

Microsoft/WPS

Operate on Excel

rpa.app.microsoft

rpa.app.wps

Microsoft/WPS

CV

Operate on controls recorded by CV

rpa.ai.cv

CV

LLM

Call Large Language Model (LLM) interfaces based on the OpenAI SDK

rpa.ai.llm

LargeLanguageModel

AliyunOCR

Use Alibaba Cloud OCR

rpa.ai.aliyun_ocr

AliyunOCR

Asset

Operate on asset variables

rpa.console.asset

Asset

Logger

Record logs

rpa.console.logger

Logger

Workbench

Set the task result

rpa.console.workbench

Workbench

Param

Operation Parameters

rpa.project.params

Param

Datatable

Operate on the Data View

rpa.project.datatable

Datatable

Resource

Operate on the project's resource folder

rpa.project.resource

Resource

No Disturb Mode

Set No Disturb Mode

rpa.system.no_disturb_mode

No Disturb Mode

Screen Unlocker

Unlock the screen

rpa.system.screen_unlocker

Screen Unlocker

Dialog

Set up a dialog box

rpa.system.dialog

Dialog

7. Extension methods

8. Local debugging in the editor

  • Record logs. For more information, see Logger.

  • Debug a specific flow method. In the toolbar, select a method in a flow to start debugging from that method.

  • Breakpoint debugging. After setting a breakpoint, you can pause, step over, step into, step out, or stop during debugging, as shown in the following figure.

9. Publish

After you develop and debug a project locally, you must publish it as an application before it can be used by multiple bots. For more information, see Publish and manage applications.

10. Iterative development

To ensure that the iterative development and testing process does not affect production applications, see Test applications and publish them online.