Skip to main content

BotScript Language Reference

In addition to the visual view, many users prefer to use Laiye Automation Platform's source code view to write a process block. The source code view uses a Laiye Automation Platform's own programming language, BotScript To describe the process block. In this chapter, we will first learn the basic rules of the BotScript Language to lay the foundation for learning the source view later.

This chapter requires readers to have a slight programming foundation, which can be found in any programming language, as long as they understand basic concepts such as variables and functions. If you have no foundation at all, please read the appendix section of the beginner developer guide first for a quick start.

Summary

As mentioned earlier, Laiye Automation Platform's design philosophy is "powerful", "simple" and "fast". In short, Laiye Automation Platform not only allows beginners without computer foundation to quickly master the writing method of process through simple learning; And let professionals with a certain programming foundation be able to implement their own process at the fastest speed.

To achieve these indicators, Laiye Automation Platform provides a visual process writing UI for beginners to quickly master; At the same time, it provides a simple, easy to learn, and natural language like UB programming language, which is convenient for professionals to quickly implement. Of course, the same process block can be displayed in two UI and can be switched at any time during development.

This chapter mainly introduces the basic grammar rules of BotScript Language. Readers with a basic programming foundation can master this rule in about two hours, and after several hours of familiarity, they can flexibly apply it.

For Laiye Automation Platform, the programming language is just a tool to express logic, and the key functions are implemented by Library or plug-ins. So, language design only includes basic logic, and all specific functions, even the most basic "delay" function, are not included in language design, but are designed separately as commands. This chapter also does not include an introduction to commands.

BotScript Language is specially designed, rather than popular programming languages such as Python, JavaScript, etc., because Laiye Automation Platform's main audience is non-technical personnel who are not computer majors but are familiar with business processes. The design of BotScript Language is as close to natural language as possible. For people who understand basic English words, they can roughly understand them even if they have not learned them.

In contrast, take JavaScript as an example. Although JavaScript is an excellent language, it can play a very high efficiency in the hands of professional programmers. Even Laiye Automation Platform itself has some code written in JavaScript. However, the extensive use of parentheses in this language can easily hinder the learning of non professionals. As shown in the following figure:

Complex JavaScript

Therefore, we have designed a special BotScript Language, and made the language as simple as possible, even using as few elements as possible except letters and numbers. In fact, we have also considered the possibility of using the popular programming language in the market, because if we do this, the workload of developing Laiye Automation Platform will be greatly reduced, but at the same time, your learning difficulty will be greatly improved. So, we rejected this approach and decided not to use popular programming languages such as Python, which is either impossible or impossible.

However, in BotScript Language, many advantages of other programming languages have been absorbed. You will see some features of Basic language, Python language and JavaScript language in the design of BotScript Language. Because on the basis of full understanding, we draw on the strengths of many families, absorb the most easily understood and commonly used parts, delete the complex and rarely used parts, and make BotScript Language concise, simple, easy to learn, and easy to use.

We believe that BotScript Language is the most suitable programming language for RPA at present.

Basic structure

The source code file of BotScript Language is in plain text format, with no limit to Extension name, and is encoded in UTF-8.

The source code of BotScript Language consists of multiple statements. Like general scripting languages, such as Python and JavaScript, BotScript Language does not have strict structure and explicitly specified entry. When executing a process block, start from the first line, skip the function definition temporarily, and then continue to execute from the line after the end of the function (refer to here ).

Generally speaking, we recommend writing only one statement per line. If it is necessary to write multiple statements, use a colon separator (:) to separate them.

If one line is not enough and needs to be folded, commas can appear in any statement( , ) Or binary operator (please refer to here ) Afterwards, it is recommended to fold the line directly without adding any additional symbols, and it is not recommended to fold the line elsewhere. But if you must wrap the line elsewhere, use a backslash( \ ) As a line break symbol. For example:

Dim a=   
1

When a row exists // When, it means that the content from now on is all comments. Included in /* */ The content in, no matter how many lines, is treated as a comment. For example:

// Here is a line of comment
/*
Here is also
a line of comment
*/

Notes play no role in the operation of process, and are only for reading convenience.

All keywords, variable names and function names in BotScript Language Case insensitive . For example: variable name abc, ABC or Abc Both are considered to be the same variable.

Variables, Constants, and Data Types

Data type

Variables are the most fundamental function in programming languages. Variables can store numbers, string values, and the values in variables can be changed at any time during runtime. Variables in BotScript Language are dynamically typed, that is, the value and type of variables can be dynamically changed during operation. This is in line with the habits of general scripting languages such as Python and JavaScript. Variables are divided into the following types: integer, Floating-point arithmetic, boolean, string, function, compound and null.

Integer values can be expressed in Decimal or hexadecimal, where hexadecimal is prefixed &H Or &h .

The value of a Floating-point arithmetic number can be expressed in a conventional way or in a Scientific notation way. For example 0.01 Or 1E-2 Or 1e-2 All represent the same Floating-point arithmetic number.

Boolean values only have True Or False , Both are not case sensitive.

Use a pair of single quotation marks for string values( ' ) Or a pair of double quotation marks( " ) Surrounded by, can be used in strings \t Represents a tab character, using \n Represents line break, using \' Represents a single quotation mark, using \" Represents double quotation marks, using \\ Represents the backslash itself (this representation is called "escape"). The middle of a string can be directly wrapped without adding any other symbols, and the newline character will also be part of the string.

You can also use three single quotes before and after each( ''' ) To represent a string, this type of string is called a long string. In a long string, you can directly write Carriage return, single quotation mark and double quotation mark without using \n , \' Or \" Escape.

The value of a functional type can only be a defined function, as detailed in the following text.

Composite values include arrays, dictionaries, etc., which will be elaborated in the next section.

The value of null type is always Null , Case insensitive.

For example:

a = 1           // 'a' is an integer variable
a = &HFF // 'a' is also an integer variable
a = True // 'a' is a boolean variable. As a dynamic type language, the type of a can change at any time
a = FALSE // 'a' is a boolean variable. Note that True and False are case insensitive
a = 'Laiye' // 'a' is a string variable
a = "Laiye
RPA" // 'a' is a string variable. You can wrap a line in a string
a = null // 'a' is a null type variable. It can be written as Null, NULL or null (case insensitive)

Variable and constant

The definition of variables is as follows:

Dim VariableName

While defining the variable name, an initial value can be assigned to the variable:

Dim VariableName = Value

If you want to define multiple variables, you can define them as follows:

Dim VariableName1 = Value1, VariableName2
Dim VariableName1 = Value1, VariableName2 = Value2

The definition of constants is similar to that of variables, except that Dim Change to Const , And the value must be specified at the time of definition:

Const ConstantName1 = Value, ConstantName2 = Value

The only difference between constants and variables is that constants can only be specified once during definition and cannot be modified later.

For example:

Dim a               // Define variable named 'a', without value assigned
Dim b = 1 // Define variable named 'b', assign the value 1 to it
Dim c, d = True // Define variable named 'c' and 'd', assign the value True to 'd'
Const e = 'Laiye' // Define variable named 'e', assign the string value 'Laiye' to it
Const f // Error:a constant must have an initial value

For named variables, constants, functions, etc., their names are collectively referred to as identifiers, which need to be defined according to certain rules.

The identifier can use English alphabet and underscores( _ ), Characters in languages other than English included in any UTF-8 encoding To represent, in addition to the first character, numbers from 0 to 9 can also be used afterwards. When English alphabet are used, variable names are not case sensitive.

BotScript Language recommends that variables be defined and used (except For Loop variables in statements Try Exception variables, function Parameter, etc. in the statement). When a variable is defined within the function scope, it belongs to Local variable and is cleared when the function exits. When defined anywhere outside the function scope, it is a process block level variable and will not be cleared during the running of a process block. Process block level variables can be defined anywhere outside the function scope, without affecting their use, or even after using variables.

If the variable is used directly without definition, Laiye Automation Platform will not report an error, but there will be a warning prompt. This warning can avoid manual errors when entering variable names, such as changing variable names cat Wrong input has become cart , Through the warning message, you will find that cart It is undefined and further identified as caused by a hand error.

Composite type

In addition to common simple data types such as integer and string, Laiye Automation Platform also supports two composite types: array and dictionary. There is no difference in the definition between the two and the definition of simple data type variables.

The representation method for array type variables is to surround them with lowercase square brackets and separate each element with commas, similar to the array definition in VBScript. Example:

Dim ArrayVariable = [Valua1, Valua2, Valua3, Valua4]

The values of multiple elements in the same array can be of any type. For example, if the value of an element is an integer, it constitutes an integer array; Multiple elements in the same array can also be of different types, such as: the first element is an integer, the second element is a string, etc; Even the elements in one array can be another array, forming a multidimensional array in the general sense. Example:

Dim ArrayVariable = [Value1, Value2, [Value11, Value22], Value4]

The representation method for dictionary type variables is to use curly braces to surround them, with names and their corresponding values as a pair, separated by commas. Example:

{ Name1:Value1, Name2:Value2, Name3:Value3 }

Among them name Can only be a string, value It can be any type of expression. If you are familiar with JavaScript or JSON, you will find that this initialization method is highly similar to the representation of JSON.

The usage method for array and dictionary type variables is: whether it is an array or a dictionary, when referencing its elements, square brackets are used as the index. Example:

VariableName[Index1]

Using this method to reference elements in an array or dictionary can be used as both left and right values, meaning that the value of the variable can be read, the content of the variable can be assigned, and even new values can be added to it. Example:

Dim Variable = [486, 557, 256]                      // Define variable with an array value
a = Variable[1] // After this, 'a' will be 557
Variable = {"key1":486, "key2":557, "key3":256} // Change the type of the variable as a dictionary
a = Variable["key1"] // After this, 'a' will be 486

Note: When referencing elements in an array or dictionary, the index of the array can only be of integer type, with 0 as the starting index; The index of a dictionary can only be of type string. If not used correctly, an error will be reported during operation.

References to arrays or dictionaries can be nested. If you want to reference an array in an array (i.e. a multidimensional array) or an array in a dictionary, you can continue to write new square brackets after it. Example:

Variable = {"key1":486, "key2":557, "key3":256}     // The type of Variable is a dictionary
Variable["key4"] = [235, 668] // Put an array into the dictionary
// After this, the value in this dictionary is {"key1":486, "key2":557, "key3":256, "key4":[235, 668]}
a = Variable["key4"][0] // After this, 'a' will be 235

Operators and Expressions

Operators in BotScript Language and their meanings are shown in the following table:

+-*/&^<<=
additionSubtraction/NegationmultiplicationdivisionConnection StringExponentiationless thanLess than or equal to
>>=<>=AndorNotMod
greater thanGreater than or equal toUnequalEquality/AssignmentLogic andLogical ORNegationTake remainder

Using operators and parentheses for variables, constants, and values ( ) Joining together is called an expression. In the above operators, Not Is a meta operator - It can be used as either a unary operator or a binary operator. Others are binary operators. The one meta operator only allows one element (variable, constant, expression or value) to appear on the right, and the two meta operator only allows two elements to appear on the left and right at the same time.

Note: When = When it appears inside an expression, its meaning is to determine whether it is equal. When = When forming an independent statement, its meaning is assignment. Here = Although the design has ambiguity, it can be better accepted by beginners.

BotScript Language deletes some operators that are not commonly used in other languages, such as integer division operator, Bitwise operation operator, etc. Because these operators have fewer usage scenarios, even if needed, they can be implemented in other ways.

Expressions are commonly used in assignment statements, which can assign a value to a variable in the form of:

VariableName = Expression

Note that when the expression is an independent (without any operator calculation) array or dictionary type variable, the assignment operation only assigns its reference, that is, simply adds an "alias" to the variable. When an element in an array or dictionary changes, the other also changes.

For example:

a = [486, 557, 256]     // 'a' is an array
b = a // 'b' is an alias of 'a'
b[1] = 558 // When change the value of 'b',the value of 'a' is also changed
c = a[1] // After this, the value of 'c' is 558,instead of 557
a = 557 // After this, the value of 'a' is 557,and its type is changed to integer
b = a // After this, the value of 'b' is also 557
b = 558 // After this, the value of 'b' is changed to 558. But the value of 'a' is not changed
c = a // After this, the value of 'c' is still 557

Logical statement

Conditional branching statement

That is, the If... Else statement most commonly used in general programming languages is mainly used to judge one or more conditions to execute different process. In BotScript Language, there are several forms:

If Condition
Statement Block 1
End If
If Condition
Statement Block 1
Else
Statement Block 2
End If
If Condition1
Statement Block 1
ElseIf Condition2
Statement Block 2
Else
Statement Block 3
End If

When the condition is met, the statement block following the condition will be executed; otherwise, the statement block will not be executed. Else The following statement blocks will only be executed when all the previous conditions are not met.

For example:

// Time.Hour() :  The number of hours in the current time can be obtained
// TracePrint() : Print the specified content to the output bar of Laiye Automation Creator

If Time.Hour() > 18 // The number of hours in the current time can be obtained
TracePrint("closing time") // Execute this statement when the hours is more than 18
Else
TracePrint("work time") // Execute this statement if the preceding conditions are not met
End If

Select Branch Statement

Select one of multiple branches based on certain conditions. Calculate first Select Case The following expression, and then determine if there is a certain Case The value of the branch and this expression are consistent. If there is no consistent Case Branch, execute Case Else The following statement block (if any).

Select Case Expression
Case Expression1, Expression2
Statement Block 1
Case Expression3, Expression4
Statement Block 2
Case Else
Statement Block 3
End Select

For example:

Select Case Time.Month()            // The number of months in the current time can be obtained
Case 1,3,5,7,8,10,12 // If Jan, Mar, May, Jul, Aug, Oct, Dec
DayOfMonth = 31 // There are 31 days in the month
Case 4,6,9,11 // If Apr, Jun, Sep, Nov
DayOfMonth = 30 // There are 30 days in the month
Case Else // If other case (just Feb left)
DayOfMonth = 28 // There are 28 days in the month (ignoring leap years)
End Select
TracePrint(DayOfMonth)

Conditional loop statement

In BotScript Language, use Do…Loop Statement to implement conditional loop, that is, loop to execute a certain sentence block when a certain condition is met. Do…Loop There are five different forms of statements, and their usage is relatively flexible:

  1. Preconditions established Loop: First determine the 'condition'. If the 'condition' is true, loop through the execution of the statement block. Otherwise, automatically exit the loop.
Do While Condition
Statement Block
Loop
  1. Pre condition not valid Loop: Contrary to the previous one, if the condition is true, exit the loop, otherwise execute the statement block in a loop.
Do Until Condition
Statement Block
Loop
  1. Postcondition is tenable Then loop: execute the statement block first, and then judge the "condition". If the "condition" is true, Continue to Loop to execute the statement block, or automatically exit the loop.
Do
Statement Block
Loop While Condition
  1. The Postcondition does not hold Then loop: execute the statement block first, and then judge the "condition". If the "condition" is true, the loop will exit automatically. Otherwise, Continue to Loop to execute the statement block.
Do 
Statement Block
Loop Until Condition
  1. infinite Loop: The loop statement itself does not make any conditional judgments. It needs to make judgments in the statement block itself. If there is no statement jumping out of the loop in the statement block, the loop will be executed indefinitely
Do
Statement Block
Loop

For example:

Do Until Time.Hour() > 18              // Judge the number of hours in the current time, and loop when it is not more than 18
TracePrint("Closing time not reached") // The statement here will be executed every time it loops
Delay(1000) // Take a second delay every time it judges
Loop
TracePrint("Closing time!") // If greater than 18, it will jump out of the loop and execute the statement here

Counting loop statement

The count loop statement is mainly used to execute a certain number of loops, and its basic form is:

For <LoopVariable> = <StartingValue> To <StopValue> Step <StepSize>
Statement Block
Next

In the count loop statement, "starting value" "stop value" , "Step size" can only be integer type or Floating-point arithmetic type; Step size can be omitted, with a default value of 1. The variable starts from the "starting value" and automatically increases the "step size" every time it loops until it is greater than "stop value" , The cycle will only end.

In count loop statements, 'loop variable' can be omitted Dim Statement definition, used directly, but cannot be used again after the loop ends.

For example:

Dim count = 0               // define a variable 'count'
For i=1 To 100 // variable 'i' will increase by 1 in every loop. variable 'i' need not to be defined
count = count + i
Next
TracePrint(count) // The result of 1 + 2 + 3 +... + 100 will be displayed here, it will be 5050

Traversal loop statement

The traversal loop statement can be used to process every element in arrays and dictionaries. There are two forms of traversal loop statements:

For Each <LoopVariable> In <ArrayOrDict>
Statement Block
Next

In this form of loop statement, each value in the array or dictionary is automatically traversed and placed in the 'loop variable' until the traversal is completed.

Alternatively:

For Each <LoopVariable1>, <LoopVariable2> In <ArrayOrDict>
Statement Block
Next

In this form of loop statement, each index and value in the array or dictionary will be automatically traversed and placed in "loop variable 1" and "loop variable 2" respectively, until the traversal is completed.

Similar to counting loop statements, in traversal loop statements, 'loop variables' can be omitted Dim Statement definition, used directly, but cannot be used again after the loop ends.

For example:

Dim days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] // define an array named 'days'
Dim count = 0
For Each i In days // the value of variable 'i' will be each value in 'days' in each loop
count = count + i // Add up each value in the array in turn
Next
TracePrint(count) // The cumulative sum of the days in each month of the year will be displayed here, which is 365

Jump statement

In BotScript Language, the following forms of loop jump statements are supported:

Break

It can only appear in the internal statement block of loop statements such as conditional loops, count loops, or traversal loops, and its meaning is to immediately jump out of the current loop.

Continue

It can only appear in the internal statement block of loop statements such as conditional loop, count loop, or traversal loop. Its meaning is to immediately end the current loop and start the next loop.

For example:

Dim days = { 'Jan':31, 'Feb':28, 'Mar':31, 
'Apr':30, 'May':31, 'Jun':30,
'Jul':31, 'Aug':31, 'Sep':30,
'Oct':31, 'Nov':30, 'Dec':31 }

For Each i,j In days // the value of variable 'i' and 'j' will be each name and value in dictionary 'days' in each loop
If j Mod 2 = 0 // if 'j' is even
Continue // Stop this loop and start the next loop
End If
TracePrint(i) // Shows the name in 'days' when the value is odd
Next

Additionally, anywhere in the process block, just write

Exit

Without any Parameter, the execution of the entire process (not the current process block) can be automatically ended when the execution reaches this line.

Function

The so-called function refers to packaging a set of commonly used functions into a statement block (called "definition"), and running this statement block in other statements (called "call"). Using functions can effectively streamline logic and avoid repetitive code writing.

The definition and invocation of a function do not have a sequential relationship, and the invocation can occur first, followed by the definition. But functions must be defined in global space, which means that function definitions cannot appear in statement blocks below other function definitions, branch statements, or loop statements.

The function definition can include Parameter, and the Parameter is equivalent to a variable. However, when calling, the caller can specify the values of these variables.

The format of the defined function is as follows:

  • Functions without Parameter
Function FuncName( )
Statement Block
End Function
  • Functions with Parameter
Function FuncName(Parameter1, Parameter2)
Statement Block
End Function

The format of Parameter definition can be just a "variable name" or "variable name=expression". For the latter, it means that this Parameter has a "default value", whose default value is determined by "Expression".

If a function has Parameter, each variable name in the Parameter is considered as a defined Local variable in the function, and it is unnecessary to use Dim Statement definition.

In the function definition, to exit the function and return, the following notation is used:

Return Value

When this statement is executed, the function will jump out and return to the next line of the calling statement. When returning, you can bring a return value (specific functions will be described below). The return value can be ignored and defaults to Null . When executing to the end of the function, regardless of whether it is written or not Return Statements will all return.

For example:

Function Add(x, y=1)        // define a function with two parameters, the second parameter has a default value
Return x + y // return the value of 'x+y'
End Function

The format for calling a function is as follows:

ReturnedVariable = FuncName(Parameter1, Parameter2)

Perhaps

FuncName(Parameter1, Parameter2)

According to the first format call, a variable can be specified as the return. After the function call is completed, the return value of the function will be automatically assigned to the return variable here. The caller can learn about the function call situation through the return value. At this point, parentheses must be added after the name of the called function. When called in the second format, the caller does not need to return a value, so the parentheses can be omitted to make the statement more in line with natural language habits.

When called, it is equivalent to performing an assignment operation on the Parameter in the function, and assigning it with the value of the expression. Similar to the rules of assignment operations, when an expression is an independent (without any operator calculation) array or dictionary, the assignment operation only assigns its reference, that is, simply adds an "alias" to the variable.

When calling a function, the number of expressions passed in can be less than the number of Parameter. If a Parameter does not have an incoming value, or the incoming value is Null , its default value is used. For Parameter without default values, values or expressions must be passed in when calling functions.

For example, for the function defined above, it can be called as follows:

a = Add(100)            // Call 'Add' function, since the second parameter has default value 1, so the value of a will be 101
b = Add(100, 200) // Call 'Add' function, specify both of the parameters, so the value of a will be 300
Add 100, 200 // Call 'Add' function, the return value is ignored, so parentheses is not necessary

After the function is defined, its name can be used as a constant of a function type, or it can be assigned to a variable, which can also be used to call the function.

For example, for the functions defined above Add , It can be used in the following way:

Dim Plus = Add
TracePrint Plus(100, 200)
// It is equivalent to calling Add first, and then call TracePrint with its return value. The result is 300

In addition to the functions defined in the flow block, various commands in the BotScript Language are actually built-in functions. For example, in the example above TracePrint It is a Intrinsic function and a command. So, when using TracePrint When commanding, both of the following methods are possible:

  • TracePrint("Hello")
  • TracePrint "Hello"

Please note that the terms "function" and "Parameter" conform to the habits of general programming languages. However, in order to better let non IT personnel understand, we often use the terms "subprogram" and "attribute" in the Laiye Automation Platform software itself to refer to "function" and "Parameter". However, since BotScript Language is introduced in this chapter, the habit of "function" and "Parameter" consistent with other programming languages is still maintained.

Other

Modules

BotScript Language supports modularization. You can call another process block written in BotScript Language in BotScript Language. Although BotScript Language does not specify an extension, if you want to call another process block of BotScript Language, the two process blocks must have the same extension.

We call the process block to be called "module". After the extension is removed, the remaining file name is the name of the module. For example, if the file name of a process block is UBTest.task, the module name is UBTest.

In BotScript Language, import a module in the following way:

Import ModuleName

Note that the writing rules for module names here are consistent with variable names, and there is no need to use double quotes or add extensions. For example, Import UBTest. When compiling and running, Laiye Automation Platform will automatically add an extension to the current process block file according to its extension, and search in the current directory. In Windows, because the file name is not case sensitive, the module name after the Import statement can also be case insensitive. In other operating systems, it is important to ensure that the module name is in the same case as the file.

Each imported module will be placed in a 'namespace' with the same name as the module name, and functions in the imported module can be called in the following way:

Namespace.FuncName

Namely, add a dot (.) between the namespace and function name to separate them.

After importing a module, you can not only call the functions defined in the module, but also directly run all commands in the process block with the module name as the function name. For example, there is a process block, ABC. task. After importing in other process blocks, you can directly call ABC. task in the following format (equivalent to running the process block ABC. task):

ABC()

Assuming that a function named test is defined in the process block ABC. task, this function can be called in the following format

ABC.test()

Exception

As a dynamically typed language, there are many errors that are difficult to check during compilation and can only be reported during runtime. Moreover, since Laiye Automation Platform does not emphasize the running speed, but rather the running stability, it will also add more checks during running. When an error occurs, a more appropriate method of reporting an error is to throw an exception. For example, when running the "targeted command" in UI elements automation, if the target cannot be found after the timeout period, an exception will be automatically thrown.

In addition to the exceptions automatically thrown, in the process block, you can also use Throw Statement threw an exception:

Throw StringValue

When throwing an exception, the relevant information of the exception can be thrown together in the form of a string, or this string can be omitted.

If the exception is not handled in the process block, when an exception occurs, the entire process will terminate execution and display the exception related information. As shown in the following figure:

An exception occurred while the process was running

If you do not want the process to terminate when an exception occurs, you can use the following statement to handle the exception:

Try
Statement Block
Catch VariableName
Statement Block
Else
Statement Block
End Try

If in the Try An exception occurred in the following statement block, causing a skip to Catch Execute in the following statement block. If in the Try No exception occurred in the statement block and defined Else Statement block (of course, it can also be omitted Else Statement block), it will jump to Else Execute within a statement block.

Catch The variable name after the statement can be omitted. If not omitted, it can be omitted Dim The statement is defined in advance. When an exception occurs, the value of this variable is a dictionary, which contains three fields: "File", "Line", and "Message", representing the file name where the exception occurred, the line number where the exception occurred, and the information contained in the exception.

For UI elements automation, sometimes it may fail due to UI stuttering, etc. In fact, it may be normal to try again. Therefore, in the Try After the statement, you can also add a 'retry count'. As follows:

Try N
Statement Block 1
Catch VariableName
Statement Block 2
Else
Statement Block 3
End Try

Here N It can be a variable, expression, or constant, but usually should be of integer type. Its meaning is:

Stay Try and Catch If an exception occurs between statements (such as "statement block 1" in the above example), it will automatically return to Try Try again when trying again N After the second attempt, if there are still anomalies, it will jump to Catch Execute the following statement (such as "statement block 2" in the example above). When in N In the first attempt, as long as there is one successful attempt, no further attempts will be made (for example, if there is no exception in the first attempt and there is no exception in the second attempt, no attempt will be made for the third time), but instead, skip to Else Execute the following statement (such as "statement block 3" in the example above).