Home

Awesome

<img src="https://raw.githubusercontent.com/tebelorg/TagUI/rpa_python/src/media/tebel_icon.png" height="111" align="right">

TagUI

Why This | Set Up | To Use | Cheat Sheet | Developers | Credits | Video

TagUI is a command-line tool for digital process automation (RPA)

Why This

The goal of UI (user interface) automation is to reproduce cognitive interactions that you have with websites or your desktop, so that your computer can do it for you, base on your schedule or conditions. TagUI helps you rapidly automate repetitive or time-critical tasks - use cases include digital process automation, data acquisition and testing apps.

Read on for more info or jump right to the flow samples section to see examples of TagUI automation in natural-language-like syntax, which makes automation easy to maintain. This is a full-feature and free open-source tool, so there's nothing to upgrade to or any paid subscription. To feedback suggestions or bugs, raise an issue on GitHub.

<details> <summary> Click to show differences between TagUI open-source RPA and commercial RPA software </summary>

Key Strengths

Neutral Differences

Key Weaknesses

</details>

HOW IT WORKS

TagUI converts your intentions from over 20 human languages to lines of working JavaScript code that perform UI automation. Under the hood, it uses Chrome DevTools Protocol, SikuliX, CasperJS, PhantomJS & SlimerJS.

// sample TagUI flow to log into Typeform and download a survey report
https://www.typeform.com
click login
type username as user@gmail.com
type password as 12345678
click btnlogin
download https://admin.typeform.com/xxx to report.csv
// besides web element identifiers, images of the elements can be used
click login_button.png
type username_box.png as user@gmail.com
// in addition (x,y) coordinates of user-interface elements can be used
click (1200,200)
type (800,400) as user@gmail.com
<details> <summary> Click to show powerful and user-friendly features of TagUI that come right out of the box </summary> </details>

Set Up

TagUI is in v5.11 - it unzips and runs directly on Windows, macOS, Linux (link to release notes)

PACKAGED INSTALLATION

PlatformmacOSLinuxWindowsNode.js (macOS/Linux)
Packageunzip and rununzip and rununzip and runnpm install tagui

Recommended locations to unzip to

Avoid spaces in the folder path as some components of TagUI don't work well with spaces in folder and file names. Optionally, configure web browser settings in tagui_config.txt, such as browser resolution, step timeout of 10s etc.

Tip - to try cutting edge version with the latest features, download master.zip to overwrite your existing packaged installation. Be sure to manually select and move the folders & files inside master.zip's TagUI-master/src folder to replace your existing tagui/src folder, some OSes will delete existing target folders that are missing from source folder.

MANUAL INSTALLATION

<details> <summary> Click to show step-by-step setup if you prefer to download dependencies manually from their websites </summary>
  1. PhantomJS (headless scriptable web browser) - http://phantomjs.org
  2. CasperJS (navigation/testing for PhantomJS) - http://casperjs.org
  3. SlimerJS (scriptable web browser for Firefox) - https://slimerjs.org
  4. TagUI (general purpose UI automation tool) - https://git.io/vMCTZ
  5. SikuliX (required for visual automation features) - http://sikulix.com
  6. PHP (only required for manual Windows setup) - http://windows.php.net

Tip - take note to put TagUI to a folder path without spaces (some dependencies have issue with that). for manual Windows setup, 1. set SLIMERJS_EXECUTABLE env variable to point to slimerjs.bat, 2. put GNU utilities (cut / gawk / grep / head / sort / tail / tee), curl ssl in tagui\src\unx, 3. add phantomjs\bin, casperjs\bin, php folders to path

</details>

To Use

COMMAND LINE

tagui flow_filename option(s) for Windows and ./tagui flow_filename option(s) for macOS/Linux

By default, log files (.log .raw .js) are created after running. To switch off, put an empty file tagui_no_logging in tagui/src folder. If your command prompt or terminal font size is too small, you can set it to much larger font sizes for easier reading. Below example runs a script to search on Yahoo website and capture screenshots of the results.

Windows - unzip the tagui folder to c:\. Open command prompt with Start Menu -> type run -> type cmd and enter

c:
cd c:\tagui\src
tagui samples\1_yahoo chrome

macOS - unzip the tagui folder to your desktop. Open terminal from Apps -> Utilities -> Terminal and enter commands

cd /Users/your_userid/Desktop/tagui/src
./tagui samples/1_yahoo chrome

Linux - unzip the tagui folder to a convenient folder on your laptop for eg /home/your_userid and enter commands

cd /home/your_userid/tagui/src
./tagui samples/1_yahoo chrome

If the script works successfully, you will notice 5 .png files - congratulations, you have run your first TagUI script!

Troubleshoot OS-specific exceptions

Troubleshoot browser-specific exceptions

More details on TagUI command-line usage

<details> <summary> Click to show the command line options for TagUI tool and their purposes (eg chrome, headless, report) </summary>
OptionPurpose
chromerun on visible Chrome web browser instead of invisible PhantomJS (first install Chrome)
headlessrun on invisible Chrome web browser instead of default PhantomJS (first install Chrome)
firefoxrun on visible Firefox web browser instead of invisible browser (first install Firefox)
reporttrack run result in tagui/src/tagui_report.csv and save html log of automation execution
uploadupload automation flow and result to hastebin.com (expires 30 days after last view)
speedskip 3-second delay between datatable iterations (and skip restarting of Chrome)
quietrun without output except for explicit output (echo / show / check / errors etc)
debugshow run-time backend messages from PhantomJS mode for detailed tracing and logging
testtesting with check step test assertions for CI/CD integration (output XUnit XML file)
baselineoutput execution log and relative-path output files to a separate baseline directory
input(s)add your own parameter(s) to be used in your automation flow as variables p1 to p9
data.csvspecify a csv file to be used as the datatable for batch automation of many records
</details> <details> <summary> Click to show info on automation logs (.log, .js, .raw), and how to run tagui from any directory </summary>

After each automation run, a .log file will be created to store output of the execution, a .js file is the generated JavaScript file, a .raw is the expanded flow after reading in any module sub-scripts that are called in that flow.

These files are created by default for user reference purpose and can be helpful in debugging or troubleshooting the automation flow. To switch off creation of these files, put an empty file tagui_no_logging in tagui/src folder.

To make tagui command accessible to run from any directory

</details> <details> <summary> Click to show how to run TagUI scripts by double-clicking as desktop icons </summary>

To do that on Windows, create a .cmd or .bat file with contents like the following, which goes to the directory where you want to run the automation, and run tagui command on the file with your specified options. Double-clicking the .cmd or .bat file will start automation. You can also associate .tagui files directly to be opened by tagui\src\tagui.cmd command.

@echo off
c:
cd c:\folder
tagui filename quiet speed chrome

To do that on macOS / Linux, create a file with contents like the following, which goes to the directory where you want to run the automation, and run tagui command on the file with your specified options. You will need to use the command chmod 700 on the file to give it execute permissions, so that it can be run by double-clicking on it.

cd /Users/username/folder
tagui filename quiet speed chrome
</details>

BY SCHEDULING

To schedule an automation flow with crontab (for macOS/Linux), for example at 8am daily

0 8 * * * /full_path/tagui/src/tagui flow_filename option(s)

For Windows, use Task Scheduler (search schedule from Start Menu) or something like Z-Cron

CHROME EXTENSION

Download from Chrome Web Store to use TagUI Chrome web browser extension for recording automation flows. TagUI Chrome extension records steps such as page navigation, clicking web elements and entering information.

<details> <summary> Click to show details on TagUI Chrome extension - based on https://github.com/ebrehault/resurrectio </summary>

After installing the Chrome extenstion, to start recording automation flows

  1. Go to the website URL you want to start the automation at
  2. Click the TagUI icon, followed by Start button
  3. Carry out the steps you want to automate
  4. Click the TagUI icon, followed by Stop button
  5. Click Export button to view generated TagUI script

While recording the steps, you can right-click to bring up a menu for steps such as showing the element identifier. The recording isn't foolproof (for example, the underlying recording engine cannot capture frames, popup windows or tab key input). It's meant to simplify flow creation with some edits, instead of typing everything manually. See this video for an example of recording a sequence of steps, editing for adjustments and playing back the automation.

</details>

NATIVE LANGUAGES

To run TagUI flows in human languages or output flow execution in other languages (see demo run)

  1. set your default flow language with tagui_language variable in tagui_config.txt
  2. write automation flow in human language base on language definition .csv files
  3. optionally set tagui_language in flow to any other languages as output language
<details> <summary> Click to show the 20+ human languages supported by TagUI and how to self-build language definitions </summary>

Tip - as Windows Unicode support isn't as straightforward as macOS/Linux, doing this in Windows may require changing system locale, using chcp command, and selecting a font to display native language correctly (more info)

TagUI language engine supports over 20 languages and can be modified or extended easily by users to improve accuracy or add more languages. The languages are Bengali, Chinese, English, French, German, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Polish, Portuguese, Romanian, Russian, Serbian, Spanish, Tagalog, Tamil, Thai, Vietnamese. This starting set is partly chosen base on the list of most commonly used languages, partly from the countries around where I'm from (Singapore), and partly from countries with a lot of developers.

If your native language isn't in the above list, you can also automate building a new human language definition by using this language build automation flow (src/languages/build) that self-builds the vocabulary set using Google Translate. To do that, update build.csv with the languages that you want to build and run tagui build using chrome in src/languages folder. Use quiet option to hide the verbose automation output. The generated files are named as their 2-character language codes to prevent overwriting existing language definitions by accident. To use the generated .csv files, rename them to their full language names. See full list of languages possible to be generated by Google Translate.

Most of the language definitions are automatically self-built using Google Translate (except english.csv, chinese.csv, japanese.csv, german.csv, french.csv which have been vetted). Native language users can update the language definition csv themselves and are invited to submit PRs with correct words to be used. Some languages are very different from English structure (for eg written from right to left) and would be impossible to use correctly in TagUI.

</details>

VISUAL AUTOMATION

TagUI has built-in integration with SikuliX (base on OpenCV) to allow visually identifying the web elements and desktop UI (user interface) elements for interaction by providing their images or (x,y) coordinates. Applicable steps are click, hover, type, select, read, show, save, snap, keyboard, mouse. To use visual automation, OpenJDK v8 (64-bit) or later is needed.

<details> <summary> Click to show how to download and check for Java, how to use visual automation & OCR, and a demo video </summary>
  1. Check that OpenJDK (64-bit) is installed (entering java -version returns your Java version)
  2. After Java is installed, you will have to restart your command prompt or terminal to use it
  3. On Windows, set display magnification to recommended %, if it doesn't work then 100%
  4. On Windows, if TagUI just hangs there, see if it's due to this issue and try the solution
  5. On macOS, if can't find image on screen, may be due to how the image was captured
  6. On Linux, requires installing and setting up dependencies by following this guide

Tip - the first time visual automation is run, the SikuliX engine will need to initialise Jython. Run again to use.

To use visual automation, simply specify an image (in .png or .bmp format) to visually look for in place of the element identifier. Relative paths are supported for image filenames (eg pc.png, images/button.bmp). Note that the element that corresponds to the image must be visible on the screen for visual automation to succeed. If it's blocked by another window for example, the automation will be unable to find the element.

Alternatively, you can specify the (x,y) coordinates of the element that you want to interact with.

Sample Visual Automation

To type onto the screen instead of a particular element, use keyboard text or keyboard [modifiers]text (examples). To do a snapshot or an OCR of the whole screen, use page.png or page.bmp as the element identifier for steps snap / read. The usual helper functions visible() / present() can also be used to check whether an image is visible on the screen.

The keyboard and mouse steps, as well as helper functions mouse_xy(), mouse_x(), mouse_y(), can be used to do complex UI interactions. A screen (real or Xvfb) is needed for visual automation. Tesseract OCR (optical character recognition) is used for visually retrieving text. Also, by using vision step, you can send custom SikuliX commands to do things that are not covered by TagUI.

Transparency (0% opacity) is supported in .png images, for eg using an image of an UI element with transparent background to enable clicking on an UI element that appears on different backgrounds on different occasions.

Another example is an image of the window or frame (PDF viewer, MS Word, textbox etc) with the center content of the image set as transparent. This allows using read, show, save, snap steps to perform OCR and save snapshots for application windows, containers, frames, textboxes with varying content. Also for these steps, (x1,y1)-(x2,y2) can be used as the identifier to define the region of interest on the screen to perform OCR or capture snapshot.

</details>

PYTHON INTEGRATION

TagUI has built-in integration with Python (works out of the box for both v2 & v3) - a programming language with many popular frameworks for big data and machine learning. The py step can be used to run commands in Python and retrieve the output of those commands. To use Python integration in TagUI, first download Python for your OS. macOS and Linux normally come pre-installed with Python. Make sure that python command is accessible from command prompt.

<details> <summary> Click to show how to use py step in your automation flow to send and receive data from Python frameworks </summary>

In your automation flow, use the py step followed by the Python commands to be executed, separated by ;. You can then use the print command in Python to output the result you want to be accessible in your automation flow as py_result variable. If the result is JSON data, the JSON object py_json will be created for easy access to JSON data elements. If not, py_json will be null.

// using py step to denote Python code, and getting back output from py_result
py a=1;b=2
py c=a+b
py print(c)
echo py_result

// alternatively, you can use py begin and py finish to denote a Python code block
// indentation of Python code is also supported, for example in conditions or loops
py begin
a=1;b=2
c=a+b
print(c)
py finish
echo py_result

// an example of passing dynamically generated variables to Python integration
phone = 1234567
name = 'donald duck'
py_step('phone = ' + phone)
py_step('name = "' + name + '"')

py print(name)
echo py_result
py print(phone)
echo py_result

Tip - you can also use the execfile() command in Python v2.X to run Python scripts. Or use exec(open('filename').read()) in Python v3.X to run Python scripts

</details>

R INTEGRATION

TagUI has built-in integration with R - an open-source software environment for statistical computing and graphics. R can be used for big data and machine learning. The r step can be used to run commands in R and retrieve the output of those commands. To use R integration in TagUI, first download R software for your OS. Make sure that Rscript command is accessible from your command prompt (added to path or symbolically linked).

<details> <summary> Click to show how to use r step in your automation flow to send and receive data from R frameworks </summary>

In your automation flow, use the r step followed by the R commands to be executed, separated by ;. You can then use the cat() command in R to output the result you want to be accessible in your automation flow as r_result variable. If the result is JSON data, the JSON object r_json will be created for easy access to JSON data elements. If not, r_json will be null.

// using r step to denote R code, and getting back output from r_result
r a=1;b=2
r c=a+b
r cat(c)
echo r_result

// alternatively, you can use r begin and r finish to denote a R code block
r begin
a=1;b=2
c=a+b
cat(c)
r finish
echo r_result

// an example of passing dynamically generated variables to R integration
phone = 1234567
name = 'donald duck'
r_step('phone = ' + phone)
r_step('name = "' + name + '"')

r cat(name)
echo r_result
r cat(phone)
echo r_result

Tip - you can also use the source() command in R to run R scripts

</details>

CLI ASSISTANT

TagUI scripts are already in natural-language-like syntax to convert to JavaScript code. What's even better is having natural-language-like syntax on the command line. Instead of typing tagui download_bank_report june creditcard to run the automation flow download_bank_report with parameters june creditcard, you can type erina download my june creditcard bank report. For a demo of the CLI (command-line interface) assistant in action, see this video.

<details> <summary> Click to show details on how you can rename your CLI assistant and the syntax used to invoke automations </summary>

The commands erina (macOS/Linux) and erina.cmd (Windows) can be renamed to any other names you like. The commands can be set up in the same way as the tagui / tagui.cmd above to be accessible from any folder. The command basically interprets this general syntax erina single-word-action fillers options/parameters fillers single-or-multi-word-context to call run the corresponding automation flow action_context with options/parameters.

Also, adding using chrome / using headless / using firefox at the end will let it run using the respective browsers. The default location where automation flows are searched for is in tagui/flows folder and can be set in tagui_helper.php. Filler words (is, are, was, were, my, me) are ignored as they don't convey useful info. More details here.

</details>

TAGUI WRITER, SCREENSHOTER & EDITOR

TagUI Writer is a Windows app created by Arnaud Degardin / @adegard which makes it easy to write TagUI scripts. By pressing Ctrl + Left-click, a popup menu will appear with the list of TagUI steps for you to paste into your text editor. Arnaud also created a ScreenShoter app which makes it easy to capture snapshots for TagUI visual automation. Lastly, TagUI Editor allows you to edit and run TagUI scripts via AutoHotKey. To download, click here.

<details> <summary> Click to show a preview of how TagUI Editor can be used to edit and run TagUI scripts </summary>

TagUI Editor

</details>

TAGUI FOR PYTHON

TagUI for Python is a Python package created by TagUI's creator Ken Soh / @kensoh. It brings the digital process automation capabilities of TagUI directly to the Python environment through a simple, expressive and powerful API. To install, pip install tagui. For its Python API and architecture, refer to the project homepage. At merely ~1k lines of code, the package is built on TagUI and its architecture is based on integration with TagUI's live mode.

FLOW SAMPLES

TagUI includes the following automation flow samples (tagui/src/samples folder)

Flow SamplePurpose
1_yahoosearches github on Yahoo and captures screenshot of results
2_twittergoes to a Twitter page and saves some profile information
3_githubgoes to a GitHub page and downloads the repository file
4_conditionsgoes through examples of using conditions in natural language
5_repositoriesshows using repositories on Russian social media site VK.com
6_datatablesset of flows uses datatables to retrieve and act on GitHub info
7_testingshows how to use check step assertions for CI/CD integration
8_hastebinused by upload option to upload flow result to hastebin.com
9_miscshows how to use steps popup, frame, dom, js, { and } block
a_facedetectuses face recognition to detect profile images on webpages
b_visualoutlookuses visual recognition for desktop MS Outlook email sending
c_chineseflowrun flow in other languages (first, change src/tagui_config.txt)

Cheat Sheet

AUTOMATION WORKFLOW

TagUI Flowchart

FIND XPATH OF WEB ELEMENT

TagUI Flowchart

STEPS DESCRIPTION

Basic StepParameters (separator in bold)Purpose
http(s)://just enter full url of webpage (`variable` for variable)go to specified webpage
clickelement to clickclick on an element
rclickelement to right-clickright-click on an element
dclickelement to double-clickdouble-click on an element
hoverelement to hovermove cursor to element
typeelement as text ([enter] = enter, [clear] = clear field)enter element as text
selectelement to select as option value ([clear] = clear selection)choose dropdown option
readelement to read (page = webpage) to variable namefetch element text to variable
showelement to read (page = webpage, ie raw html)print element text to output
saveelement (page = webpage) to optional filenamesave element text to file
snapelement (page = webpage) to optional filenamesave screenshot to file
snap (pdf)page to filename.pdf (headless Chrome / PhantomJS)save webpage to basic pdf
loadfilename to variable nameload file content to variable
echotext (in quotation marks) and variablesprint text/variables to output
dumptext (in quotation marks) and variables to optional filenamesave text/variables to file
writetext (in quotation marks) and variables to optional filenameappend text/variables to file
variable_name= value (for text, put in quotes, use + to concat)define variable variable_name
// (on new line)user comments (ignored during execution)add user comments
askquestion or instruction for user (reply stored in ask_result)ask user for input
livetry steps or code interactively for Chrome / visual automationenter live mode (Firefox not yet)

Tip - to use variables where text is expected, `variable` can be used. XPath is an expressive way to identify web elements. If you know xpath and use xpath for element identifier, use double quotes for text //*[@title="Login"]

<details> <summary> Click to show pro steps - tagui, keyboard, mouse, table, wait, check, upload, api, run, dom, js, r, py, vision, timeout </summary>
Pro StepParameters (separator in bold)Purpose
taguirelative or absolute filename (see MODULES section)run another tagui flow
keyboardkeystrokes and modifiers (using visual automation)send keystrokes to screen
mousedown or up (using sikuli visual automation)send mouse event to screen
tableelement (XPath selector only) to optional filename.csvsave basic html table to csv
waitoptional time in seconds (default is 5 seconds)explicitly wait for some time
checkcondition | text (in quotes) if true | text (in quotes) if falsecheck condition and print result
uploadelement (CSS selector only) as filename to uploadupload file to website
downloadurl to download to filename to savedownload from url to file
receiveurl keyword to watch to filename to savereceive resource to file
frameframe name | subframe name if anynext step or block in frame/subframe
popupurl keyword of new tab window to look fornext step or block in new tab window
{ and }use { to start block and } to end block (on new line)define block of steps and code
apifull url (including parameters) of api callcall api & save response to api_result
runOS shell command including parametersrun OS command & save to run_result
domjavascript code for document object modelrun code in dom & save to dom_result
jsjavascript statements (skip auto-detection)treat as JS code explicitly
rR statements for big data and machine learningrun R statements & save to r_result
pypython code for big data and machine learningrun python code & save to py_result
visioncustom visual automation commandsrun custom sikuli commands
timeouttime in seconds before step errors outchange auto-wait timeout

For headless and visible Chrome, file downloads can be done using normal webpage interaction or by specifying the URL as a navigation flow step. For Firefox and PhantomJS, the download and receive step can be used. Note that on Windows, snap step requires display magnification to be set at 100% to work properly.

As TagUI default execution context is local, to run javascript on webpage dom (eg document.querySelector) use dom step. Set dom_json variable to pass a variable for use in dom step. Or dom_json = {tmp_number: phone, tmp_text: name} to pass multiple variables for use in dom step (dom_json.tmp_number and dom_json.tmp_text).

</details>

CONDITIONS EXAMPLES

<details> <summary> Click to show how conditions and loops can be expressed in natural language or JavaScript </summary>
Condition (in natural language)JavaScript
example - if day equals to "Friday"if (day == "Friday")
example - if menu contains "fruits"if (menu.indexOf("fruits")>-1)
example - if A more than B and C not equals to Dif ((A > B) && (C != D))
example - for n from 1 to 4for (n=1; n<=4; n++)]
example - for n from 1 to infinityfor (n=1; n<=1024; n++)]
example - while cupcakes equal to 12while (cupcakes == 12)
contain.indexOf("text")>-1
not contain.indexOf("text")<0
equal to==
not equal to!=
more than / greater than / higher than>
more than or equal to / greater than or equal to / higher than or equal to>=
less than / lesser than / lower than<
less than or equal to / lesser than or equal to / lower than or equal to<=
and&&
or||

Use { and } step to define step/code blocks for powerful repetitive automation with for loop. The usual break and continue commands can be used on next line after an if condition, to break out of the immediate loop or continue to the next iteration. To loop 'indefinitely' use for n from 1 to infinity, where infinity is a pre-defined variable at 1024.

When using contain / equal, you can write with or without s behind. You can use if present('element') to check if the element exists, before doing the step on next line. Other useful functions include visible('element'), count('element'), url(), title(), text(), timer(), which can be used in conditions and steps such as check or echo.

</details>

HELPER FUNCTIONS

<details> <summary> Click to show csv_row(), present(), visible(), count(), clipboard(), url(), title(), text(), timer(), mouse_xy() functions </summary>
FunctionPurpose
csv_row(row_array)return formatted string for writing to csv file, eg using write step
present('element')return true or false whether element identifier specified is present
visible('element')return true or false whether element identifier specified is visible
count('element')return number of elements matching element identifier specified
clipboard('text')put text to clipboard (eg to paste text quickly with keyboard step)
clipboard()return clipboard text (eg to access text copied with keyboard step)
url()return page url of current web page
title()return page title of current web page
text()return text content of current web page
timer()return time elapsed in sec between calls
mouse_xy()return (x,y) coordinates as string, for eg '(200,400)'
mouse_x()return x coordinate as integer number, for eg 200
mouse_y()return y coordinate as integer number, for eg 200

csv_row() is useful for organising lots of data gathered during automation to be written into csv output file -

// example of using csv_row() function to save data as CSV file
read name_element to name
read price_element to price
read details_element to details
item_info = [name, price, details]
write csv_row(item_info) to product_list.csv

clipboard() is useful for accessing text on the clipboard or putting text there (for eg to paste text quickly) -

// example of using clipboard() to retrieve text contents from PDF file
dclick pdf_document.png
wait 3 seconds
keyboard [ctrl]a
keyboard [ctrl]c
text_contents = clipboard()

// example of using clipboard('text') to type text quickly by pasting it
text_to_type = 'long string of text to be entered into UI element'
click my_life_story_textbox
js clipboard(text_to_type) or clipboard(text_to_type);
keyboard [ctrl]v

mouse_xy(), mouse_x(), mouse_y() require visual automation and can be used to interact with UI (user-interface) elements on the screen by specifying their (x,y) coordinates, for eg below clicking to the right of an UI element by 200 pixels -

// example of using mouse_xy(), mouse_x(), mouse_y() functions
hover element.png
echo mouse_xy()
x = mouse_x() + 200
y = mouse_y()
click (`x`,`y`)
</details>

MODULES

<details> <summary> Click to show how you can use tagui step to call other TagUI automation flows within an automation flow file </summary>

The tagui step works by expanding content of a sub-script into the parent script, at the line where tagui step is used to call the sub-script. Thus variables that are accessible from the parent flow file will also be accessible from the sub-script. A .raw file will be created to store expanded contents of the automation flow (useful for checking error messages).

</details>

REPOSITORIES

<details> <summary> Click to show how you can use repositories csv to make objects reusable and improve readability </summary>
OBJECTDEFINITION
emailuser-email-textbox
create accountbtn btn--green btn-xl signup-btn
type emailtype `email` as user@gmail.com
</details>

DATATABLES

<details> <summary> Click to show how datatable csv files can be used to perform batch automation at scale </summary>
#testnameusernamepasswordpairsizedirection
1Trade USDSGDtest_account12345678USDSGD10000BUY
2Trade USDSGDtest_account12345678USDJPY1000SELL
3Trade EURUSDtest_account12345678EURUSD100000BUY

Tip - use speed option to skip the 3-second delay between iterations (and skip restarting of Chrome browser)

</details>

AUDIT & REPORTING

<details> <summary> Click to show how the report option can be used to track and store automation results </summary>
#AUTOMATION FLOWSTART TIMEFINISH TIMEERROR STATUSLOG FILE
1/Users/kensoh/Desktop/download_flowSun Apr 07 2019 17:33:58 GMT+0800 (+08)32.1SUCCESS/Users/kensoh/Desktop/download_flow_1.html
2/Users/kensoh/Desktop/upload_flowNOT STARTEDNOT FINISHED[LINE 1] cannot understand step self-destruct/Users/kensoh/Desktop/upload_flow_2.html
3/Users/kensoh/Desktop/update_flowNOT STARTEDNOT FINISHED[LINE 1] cannot understand step reboot computer/Users/kensoh/Desktop/update_flow_3.html
4/Users/kensoh/Desktop/booking_flowSun Apr 07 2019 17:39:00 GMT+0800 (+08)NOT FINISHEDcannot find confirm_booking/Users/kensoh/Desktop/booking_flow_4.html
</details>

Developers Reference

TagUI excels in automating user-interface interactions. It's designed to make prototyping, deployment and maintenance of UI automation easier by minimizing iteration time for each phase. Originally developed by a frustrated test automation engineer, to maximize automation code output with minimal coding efforts when automating web interactions.

API

<details> <summary> Click to show how to use API webservice that comes with TagUI and how to make complex outgoing API calls </summary>

Automation flows can also be triggered via API URL. TagUI has an API service and runner for managing a queue of incoming requests via API (for macOS/Linux). To set up, add a crontab entry on your server with the desired frequency to check and process incoming service requests. Below will check every 15 minutes and run pending flows in the queue. If there's an automation in progress, TagUI will wait for the next check instead of concurrently starting a new run.

0,15,30,45 * * * * /full_path_on_your_server/tagui_crontab

To call an automation flow from your application or web browser, use below API syntax. Custom input(s) supported. The default folder to look for flow_filename would be in tagui/src folder. Automation flows can also be triggered from emails using the API. For email integration, check out Tmail. It's an open-source mailbot to act on incoming emails or perform mass emailing; it also delivers emails by API. Emails with run-time variables can be sent directly from your flow with a single line (see flow sample 6C_datatables). For sending SMS, you can use api step to send through SMS-sending services, or host your own from your webserver using services like Skebby (see this example from @adegard). If you have data transformation in your process pipeline check out TLE, which can help with converting data.

your_website_url/tagui_service.php?SETTINGS="flow_filename option(s)"

Besides integrating with web applications, TagUI can be extended to integrate with hardware (eg Arduino or Raspberry Pi) for physical world interactions or machine learning service providers for AI decision-making ability. Input parameters can be sent to an automation flow to be used as variables p1 to p9. Output parameters from an automation flow can be sent to your Arduino or application API URL (see samples 3_github and 6C_datatables).

For making outgoing API calls in your automation flow, to feed data somewhere or send emails etc, use the api step followed by full URL (including parameters) of the API call. Raw response from API will be saved in api_result variable. If the API response is JSON data, the variable api_json will be created for easy access to JSON data elements. If not, api_json will be null. For example, api_json.parent_element.child_element retrieves value of child_element.

api_config = {method:'PUT', header:['Header1: value1','Header2: value2'], body:{'id':123,'pwd':'abc'}};

For advanced API calls, you can set above api_config variable which defaults as {method:'GET', header:[], body:{}}. Besides GET, you can use other methods such as POST, PUT, DELETE etc. You can define multiple headers in the format 'Header_name: header_value' and provide a payload body for PUT requests for example. You can set it as above before using the api step, or set using api_config.method = 'PUT'; and api_config.header[0] = 'Header1: value1'; etc. api_config.body will be automatically converted to JSON format for sending to API endpoint.

In addition, macOS/Linux/Windows commands can be executed using run step. This can be used to call other apps or services hosted locally on the OS, instead of being hosted through webservices. To use run step, specify the full command including parameters. Execution result will be stored in run_result, which can be used in your flow.

</details>

CHROME

<details> <summary> Click to show how TagUI has native integration with visible and headless Chrome using DevTools Protocol </summary>

TagUI has built-in integration with Chrome web browser to run web automation in visible or headless mode. It uses a websocket connection to directly communicate automation JavaScript code and information to Chrome.

To develop new custom methods for Chrome integration, see this TagUI issue and tagui_header.js for examples of websocket calls from TagUI to Chrome (via Chrome DevTools Protocol). The function chrome_step(method, params) sends message to Chrome and returns the response. You will see examples from simple websocket calls such as getting webpage title to stacked ones such as handling of frame or popup window. To tweak how TagUI launches / kills Chrome and the integration PHP process, see TagUI runner script for macOS/Linux or Windows.

Probably the best way to see the websocket communication in action is to enter TagUI live mode (add live step in your automation flow), then tail -f tagui_chrome.log in another terminal to see the Chrome DevTools Protocol messages going to and fro as you enter TagUI steps or JavaScript code. If you are running on Windows, you can click on the PHP process window directly to see the messages.

At run-time TagUI will start a PHP thread in the background to manage the integration with Chrome for concurrent communication. The Textalk PHP websocket is used as it's super-light and most importantly, it works even without any update for 2 years. The normal approach to integrate with Chrome is through chrome-remote-interface project or tools such as Puppeteer and friends. However, that approach introduces Node.js dependency which means users without a Node.js development environment cannot run TagUI with Chrome.

In order to retain TagUI unzip and run functionality, the approach of launching a separate PHP thread is chosen. Since the TagUI natural language interpreter is already written in PHP, there is no new dependency. Also, doing websocket communication within the single-threaded JavaScript environment used by CasperJS is not possible as it involves a redesign of fundamental CasperJS methods such as casper.exists to support async/await or use JavaScript promises which are not yet supported by CasperJS (for compatibility with latest PhantomJS).

Like chrome-remote-interface, TagUI communicates with Chrome through Chrome DevTools Protocol. The protocol is primarily designed for debugging the web browser instead of web automation, so many methods are still in experimental status. However, the API is stable enough for TagUI steps to work with Chrome. When chrome or headless option is used, TagUI replaces CasperJS methods it uses with custom methods to talk to Chrome instead of PhantomJS. When firefox option is used or by default, TagUI doesn't invoke custom methods and PHP process.

</details>

TESTING

<details> <summary> Click to show details of how TagUI can be used for test automation with integration to CI tools </summary>

The check step allows easy testing of conditions. When the test option is used, test assertions are automatically performed for check steps. This lets CasperJS framework output a XUnit XML file, which can be used for CI/CD integration with tools such as Jenkins. Below are examples of check steps, more examples in sample flow 7_testing.

// check whether the element search-buttons exists
check present('search-buttons') | 'search button exists' | 'search button does not exist'

// check whether the search button text is correct
read search-buttons to button
check button equals to 'Search' | 'search button text is correct - ' button | 'search button text is wrong - ' button

// check that the page has the text My Portfolio
check text() contains 'My Portfolio' | 'page text contains My Portfolio' | 'page text does not contain My Portfolio'

// check that number of header menu items are more than or equals to 6
check count('uh-tb-') more than or equals to 6 | 'header menu items >= 6' | 'header menu items < 6'

CasperJS test scripts are inherently different in structure and syntax from its usual automation scripts. With the test option, TagUI automatically sets up your automation flow to work as a test script. TagUI allows you to reuse the same flow for testing or automation by running it with or without the test option. More info about CasperJS testing framework.

Note that CasperJS is not yet supporting Chrome, below additional examples using CasperJS built-in test assertions won't work when chrome or headless option is used. TagUI smart selector can still be accessed using tx('selector'). As TagUI allows you to write JavaScript / CasperJS code directly within the automation flow, advanced testing or coding techniques that can be implemented in CasperJS should work directly within your flow.

test.assertTextExists('ABOUT','Check for ABOUT text');
test.assertSelectorHasText(tx('header'), 'Interface automation','Check for phrase in header element');

In the event you get an error saying that it cannot understand the step for your JavaScript line, raise an issue or modify the source code (tagui_parse.php is where interpretation of natural language to CasperJS JavaScript code takes place). Alternatively, use step js to explicitly declare that whatever follows on that line is JavaScript code and ensure that the line is not treated as a TagUI step.

</details>

FILES

<details> <summary> Click to show details of the different files used by TagUI and their purposes </summary>
Core FilesPurpose
taguimain runner for TagUI automation
tagui.cmdmain runner for Windows platform
tagui_config.txtweb browser settings used for automation
tagui_parse.phpto interpret natural language into code
tagui_header.jstemplate for CasperJS / integrations code
tagui_footer.jstemplate for CasperJS / integrations code
test/positive_testTagUI's interpretation positive test cases
test/positive_test.signature.js signature for positive test cases
Multi-LanguagePurpose
translate.phptranslation engine for native languages
translate.logtranslation in English reference language
languages/buildscript to self-build language definitions
languages/build.csvdefault languages to be self-built
Chrome IntegrationPurpose
tagui_chrome.phpPHP thread for Chrome integration
tagui_chrome.loglog for Chrome websocket transactions
tagui_chrome.ininterface in-file for Chrome integration
tagui_chrome.outinterface out-file for Chrome integration
SikuliX IntegrationPurpose
tagui.pyinterface for SikuliX visual automation
tagui.loglog for SikuliX Python transactions
tagui_windows.logsame as above but for Windows
tagui_sikuli.ininterface in-file for SikuliX integration
tagui_sikuli.outinterface out-file for SikuliX integration
tagui_sikuli.txtTesseract OCR integration interface file
Python IntegrationPurpose
tagui_py.pyinterface for Python integration
tagui_py.loglog for Python platform transactions
tagui_py_windows.logsame as above but for Windows
tagui_py.ininterface in-file for Python integration
tagui_py.outinterface out-file for Python integration
tagui_py.txtintegration file for storing output
R IntegrationPurpose
tagui_r.Rinterface for R integration
tagui_r.loglog for R platform transactions
tagui_r_windows.logsame as above but for Windows
tagui_r.ininterface in-file for R integration
tagui_r.outinterface out-file for R integration
tagui_r.txtintegration file for storing output
API ServicePurpose
tagui_crontabto run service request batch from crontab
tagui_runner.phpretrieving service requests from queue
tagui_service.phpreceiving service requests into queue
tagui_service.loglog to track service requests history
tagui_service.inlog to track incoming service requests
tagui_service.outlog to track processed service requests
tagui_service.actservice request batch ready to execute
tagui_service.runservice request batch currently running
tagui_service.doneservice request batch finished running
CLI AssistantPurpose
erinanatural language command line helper
erina.cmdsame as above but for Windows platform
tagui_helper.phpcommand line natural language parser
tagui_helpergenerated normal TagUI command to run
tagui_helper.cmdsame as above but for Windows platform
Miscellaneous FilesPurpose
end_processeskill all processes of TagUI and integrations
end_processes.cmdsame as above but for Windows platform
tagui_datatable.csvtemporary datatable internal representation
transpose.phptranspose conventional datatable csv file
tagui_report.phpto track run results and keep html logs
tagui_report.csvrun results tracked using report option
sleep.phpallow adding execution pause on Windows
User-defined FilesPurpose
tagui_local.csvlocal repository (put in same folder as flow)
tagui_global.csvglobal repository (put in tagui/src folder)
tagui_local.jslocal functions (put in same folder as flow)
tagui_global.jsglobal functions (put in tagui/src folder)
</details>

SECURITY

<details> <summary> Click to show details of security concerns and features of TagUI </summary>

Below architecture diagram for TagUI will be used to elaborate on the topic of security -

TagUI Flowchart

As TagUI and the foundation it's built on is open-source software, it means users can read the source code of TagUI and all its dependencies to check if there is a security flaw or malicious code. This is an advantage compared to using commercial software that is closed-source, as users cannot see what is the code behind the software.

Following are links to the source code for TagUI and its open-source dependencies. You can dig through the source code for the other open-source dependencies below, or make the fair assumption that security issues would have been spotted by users and fixed, as these projects are mature and have large user bases.

Following are more comments specific to TagUI for the topic of security -

</details>

Credits

License

TagUI is open-source software released under Apache 2.0 license