Skip to main content

Indented Workflow

Command description​

Create an indented workflow block using any Python statement that supports indentation, such as try, except, with, for, while, or if.

Command Input Parameters​

input parametersInput parameter typeDescription
CodePythonStatementAn indented Python statement such as try:, except, with, for, while, or if

Command Output Parameters​

None

Example​

  • Catch custom exceptions

    [
    {
    "ins": "Indented Workflow",
    "in": "try:",
    "children": [
    {
    "ins": "Open Webpage",
    "in": {
    "Browser Type": "'Google Chrome'",
    "url": "'runavelo.com'",
    "Page Load Timeout": "30"
    },
    "out": {
    "Webpage Object": "web_page"
    }
    },
    {
    "ins": "Click Web Element",
    "in": {
    "Webpage Object": "web_page",
    "Web Element": "'f65c8477-c610-4973-9cef-8d5463631c1a'",
    "Click Type": "'CDP Silent Click'"
    }
    }
    ]
    },
    {
    "ins": "Indented Workflow",
    "in": "except OutOfTimeException as e:",
    "children": [
    {
    "ins": "Print Log",
    "in": {
    "Log Content": "f'Timeout exception:{e}'",
    "Render HTML": "False"
    }
    }
    ]
    },
    {
    "ins": "Indented Workflow",
    "in": "except Exception as e:",
    "children": [
    {
    "ins": "Print Log",
    "in": {
    "Log Content": "f'other:{e}'",
    "Render HTML": "False"
    }
    }
    ]
    }
    ]

    Generated Python code

    try:
    web_page = open_web_page('runavelo.com', "Google Chrome", '30', None)
    click_web_element(web_page, ElementDescriptor('f65c8477-c610-4973-9cef-8d5463631c1a', "Download"), {"clickOption":"CDP Silent Click"})
    except OutOfTimeException as e:
    print_to_app(f'Timeout exception:{e}', {"renderHtml":False})
    except Exception as e:
    print_to_app(f'Other exceptions:{e}', {"renderHtml":False})
  • Use a lock to serialize part of a parallel loop

    Generated Python code

    mylock = check_and_convert_vars(threading.RLock(), "Any type")
    def ____parallel_execute2(____rpa_gen_itr_loop_index, item):
    with mylock:
    print_to_app(f"Parallel execution: {item}", {"renderHtml":False})
    pause_sec(3)
    print_to_app(f"Execution completed: {item}", {"renderHtml":False})
    parallel_loop(['a','b','c'], False, ____parallel_execute2)
  • Read a file with with

    [
    {
    "ins": "Indented Workflow",
    "in": "with open('hello.txt') as f:",
    "children": [
    {
    "ins": "Run Python Code",
    "in": {
    "Python Code": "result = f.read()"
    }
    },
    {
    "ins": "Print Log",
    "in": {
    "Log Content": "result",
    "Render HTML": "False"
    }
    }
    ]
    }
    ]

    Generated Python code

    with open("hello.txt") as f:
    result = f.read()
    print_to_app(result, {"renderHtml":False})
  • In addition to using the Count Loop command, you can write a Python for statement in an Indented Workflow.

    [
    {
    "ins": "Indented Workflow",
    "in": "for i in range(3):",
    "children": [
    {
    "ins": "Print Log",
    "in": {
    "Log Content": "i",
    "Render HTML": "False"
    }
    }
    ]
    }
    ]

    Generated Python code

    for i in range(3):
    print_to_app(i, {"renderHtml":False})