高级命令说明?

Saving run results of flow?

You can save an html log of the run and the flow run results to tagui/src/tagui_report.csv with the -report option (shortcut -r).

tagui my_flow.tag -report

The CSV file will show one line for each run, when it started, how long it took to complete, any error message during run, the link to the log file for that run, and the user’s workgroup\userid.

处理异常和错误?

当流程没按预期进行时,有3种方法可以在Tagui中处理。

第一种方式是针对单条指令错误处理,可以增加 if 判断来预防。例如,检查是否缺少某些UI元素,然后执行XYZ步骤。使用这种方式。

第二种方式是对针对某个流程的错误处理。类似下面的语法,当 Flow.tag 成功运行时才运行。当它检测到丢失(缺少截图文件)或其他一些未知错误时,Tagui将自动抛出错误。

Windows 代码例子:

call tagui flow.tag || tagui error.tag
call tagui flow.tag && tagui success.tag

macOS / Linux 代码例子:

tagui flow.tag || tagui error.tag
tagui flow.tag && tagui success.tag

第三种方式是全局错误处理。可以为TagUI进行配置,使得在每次运行后,完成指定指令,将从报表选项生成的数据或文件发送到某些目标文件夹或API端点以进行错误/成功处理。
The third way is global error handling. Configuration can be done for TagUI such that after every run, special handling is done to send data or files generated from the report option to some target folder or API endpoint for error / success handling. For example, syncing all automation runs to central storage for auditing purpose. The special handling applies to all TagUI flows that are run.

DataTables数据表格批量自动化?

DataTables是 csv 文件,可以把数据表格作为变化,多次循环运行流程。

Datatable数据文件 (trade_data.csv) 类似下面格式:

# trade username password pair size direction
1 Trade USDSGD test_account 12345678 USDSGD 10000 BUY
2 Trade USDSGD test_account 12345678 USDJPY 1000 SELL
3 Trade EURUSD test_account 12345678 EURUSD 100000 BUY

要使用它,您可以使用tagui my_flow.tag trade_data.csv。TagUI会使用 my_flow.tag运行您的流程。 TagUI将用DataTable中的每一行(除标题行)运行 my_flow.tag 一次。

在流程运行中,TagUI会用到变量 trade, username, password,就像它们处于本地对象存储库中,并且值将来自该运行的行。Within the flow, TagUI can use the variables etc as if they were in the local object repository and the values will be from that run’s row.

To know which iteration your flow is in you can use the iteration variable:

echo current iteration: `iteration`
if iteration equals to 1
  // go to login URL and do the login steps
  www.xero.com

// do rest of the steps for every iteration

Object repositories for reusability?

Object repositories are optional csv files which can store variables for use in flows. They help to separate your flows from your personal data (like login information for web flows), and allow you to share common information between multiple flows for easy updating.

Each flow has a local object repository and all flows share the global object repository. The local object repository is the tagui_local.csv in the same folder as the flow. The global object repository is the tagui_global.csv in the tagui/src/ folder.

An object repository could look like this:

object definition
email user-email-textbox
create account btn btn–green btn-xl signup-btn

Within the flow, TagUI can use the objects email, create account as variables and they will be replaced directly by the definitions before it is run. Local definitions take precedence over global definitions.

If user-email-textbox was the identifier for some web text input, then you could use the following in your flow:

type `email` as my_email@email.com

调用流程?

在面对复杂大流程的时候,我们建议把流程分为多个子流程,然后用主流程进行调用的方式来开发。

这样做的一些常见原因包括通过保持子流中的步骤序列,或者在单独的子流中存储更容易组织的内容更容易组织的一些常见原因。例如,py开始和py完成代码块)。Some common reasons for doing that include the convenience of reusing the same subflow in other flows, doing something specific which is easier to organise by keeping the sequence of steps in a subflow, or storing your Python or JavaScript code and functions in separate subflows (using py begin and py finish code blocks for example).

在一个流程内调用另一个流程,命令如下:

tagui login_crm.tag

被调用流程也可以存储在子文件夹中:

// Windows example
tagui CRM\login.tag

// Mac/Linux example
tagui CRM/login.tag

变量可以在父流程和子流程之间使用:(可以理解成变量是全局的)

// username 和 password 变量可以被使用在 login.tag
username = 'jennifer'; password = '12345678';
tagui login.tag

// 也可以把变量分行来写,这样更清晰
username = 'jennifer'
password = '12345678'
tagui login.tag

// 在子流程 login.tag 里,也可以定义和返回变量,给父流程使用
echo `login_result`

可以在父子流中赋值变量 action = 'login',配合 if 来控制具体执行哪个子流程:

// crm_steps.tag
if action equals to 'login'
  do some steps
  do some more steps

else if action equals to 'report'
  do some steps
  do some more steps

else if action equals to 'logout'
  do some steps
  do some more steps

else
  echo ERROR - action undefined

Turbo mode 极速模式,10倍速运行?

运行流产时,可使用 turbo 参数开启极速模式(谨慎使用):

tagui flow.tag -turbo

or

tagui flow.tag -t

大多数网站和桌面应用程序都无法适应TagUI的极速模式。如果您的RPA以超出这些网站的速度运行,经常会报错。报错的点可能是字段和数据未正确填写,表单缺少数据等。

极速模式下问题可能会随机发生,包括在您的PC上工作,但由于CPU速度的差异而无法在另一台PC上工作。因此,不建议使用Turbo极速模式。实际应用中,如果用极速模式造成某些数据错误,您可能最终需要花费更多时间来排除或修复错误造成的后果。

但是,极速模式对某些特定场景的某些用户非常有用。例如,从应用程序中获取数据,超越人类速度的Web端数据输入等。使用前请反复测试流程在极速模式下的稳定性!

视觉自动化 using OCR?

您可以使用 using ocrusing OCR 告诉 TagUI 使用OCR(字符识别)在屏幕上和一些UI元素交互。参考下面代码示例,可以使用OCR的命令有:click, rclick, dclick, hover, type, select, read, snap, exist(), present()。

click Submit using ocr

if exist('Special Offer using ocr')
  click Add To Cart using OCR

// various usage combinations for select step
select Dress Color using OCR as Dark Blue using OCR
select dress_color.png as Bright Pink using ocr
select Dress Color using OCR as dark_black.png
select dress_color.png as bright_white.png

如果 .png 文件使用了 100% 透明度, TagUI 的 OCR 识别目标是该透明图片后面的背景。

Conversely, you can also remove the foreground content near some anchor element like a frame, to allow you to OCR varying content in the empty area using the read step.

在流程中编写Python?

您可以在 TagUI 流程中编写 Python 代码。Python 开发环境需要单独安装。点这里安装Python环境.

使用 py 命令告诉 TagUI 调用 python 运行python命令。您可以将字符串值传递回 TagUI 然后在Python里 print()。 Python 运行结果将存放到 TagUI 变量 py_result 里。

py a=1
py b=2
py c=a+b
py print(c)
echo `py_result`

你也可以使用 py beginpy finish 来告诉 TagUI 这部分是 Python 语言:

py begin
a=1
b=2
c=a+b
print(c)
py finish
echo `py_result`

您可以这样将变量传递给Python:

phone = 1234567
py_step('phone = ' + phone)
py print(phone)
echo `py_result`

name = 'Donald'
py_step('name = "' + name + '"')
py print(name)
echo `py_result`

要传递并返回更复杂的数据,例如多个变量,您可以使用 JSON格式 发送和接收JSON字符串。请参考这里传递2个变量,执行一些处理,并返回2个变量。

创建运行Log日志便于调试?

要执行高级调试,可以通过在 tagui/src/中创建一个空的tagui_logging文件,在运行流程时记录运行日志。

  • my_flow.log 存储一步步的执行记录。
  • my_flow.js 是已运行的生成的JavaScript文件。
  • my_flow.raw is the expanded flow after parsing modules.

运行云端 TagUI?

您可以使用 免费 Google 服务器运行Web浏览器或手机上的 Tagui。您可以在浏览器的不同选项卡上同时运行最多5个会话。

For more control running on the cloud, you can run this Docker image (use edge tag for the latest version) or Docker file on your preferred cloud vendor. See TagUI Docker video tutorial). Or run on free Node-RED instance on OpenFlow. The Docker image, Docker file and OpenFlow cloud are maintained and sponsored by Allan Zimmermann.