Skip to content

TagUI RPA Scripts

How to run these scripts

Assuming you have TagUI installed you can run these scripts by pasting the code into a .tag file and running them from a terminal with the tagui command:
tagui scriptname.tag


Sample RPA Test Page

The web scripts reference a custom RPA Test Page

Script 1: Get Web Page Content And Save To File

Script 1
//Script 1: Get Web Page Content And Save To File
//tagui script1.tag -h

https://verdapress.uk/services/test-bed

// READ XPATH ELEMENT TO VARIABLE

read /html/body/div[3]/main/div/div[3]/article/div[1] to webVar

// CREATE NEW FILE AND FILL WITH VARIABLE VALUE
dump `webVar` to script1.txt

Script 2: Create Variables To Store Data

Script 2
// Script 2: Create Variables To Store Data
//tagui script2.tag -h

name="Alex Brown"
company="VerdaPress"

// USE BACKTICKS WHEN REFERENCING VARIABLES

dump `name` `company` to script2.txt

Script 3: If Condition - Check Url

Script 3
// Script 3: If Condition - Check Url
//tagui script3.tag

https://verdapress.uk/services/test-bed

wait 2

if url() contains "test"

 // DON'T FORGET TO INDENT AFTER IF

 https://verdapress.uk/blog/posts/

 // WAIT 2 SECONDS

wait 2

Script 4: Write Variable Data to File

Script 4
// Script 4: Write variable data to file
//tagui script4.tag -h

name="Alex Snow"
company="VerdaPress"
name2 = "Joseph Smith"
company2 = "Smith Consulting"
name3 = "Helen Jones"
company3 = "CloverField"

write `name` from `company` to script4.txt
write `name2` from `company2` to script4.txt
write `name3` from `company3` to script4.txt

Script 5: Load File To Variable Write To File

Script 5
// Script 5: Load File To Variable Write To File
//tagui script5.tag -h

// FILE SUPPLIED IN DOWNLOAD BUT USE ANY TXT FILE YOU LIKE
load sample_data.txt to rpaVar

write `rpaVar` to script5.txt

Script 6: Capture Screen As PNG

Script 6
// Script 6: Capture Screen As PNG
//tagui script6.tag -h

// CAN ALSO CAPTURE BASED ON DOM, XPATH, REGION, IMAGE IDENTIFIERS

https://verdapress.uk/services/test-bed

// PAGE CAPTURES ENTIRE WEB PAGE

snap page to websnap.png

Script 7: Ask for User Input

Script 7
// Script 7: Ask for User Input
//tagui script7.tag

ask Which website would you like to visit? (No need to enter https://)

wait 1

https://`ask_result`

wait 5

Script 8: Check Condition Of Page Title

Script 8
// Script 8: Check Condition Of Page Title
//tagui script8.tag

//CHECK TITLE IF TRUE GOTO TAGUI COURSE DETAILS ELSE GOOGLE
https://verdapress.uk/services/test-bed
  if title() contains 'RPA'
    click Blog
    wait 5
  else
    https://google.com

Script 9: Write Page Content To Text File

Script 9
// Script 9: Write Page Content To Text File
//tagui script9.tag -h

https://verdapress.uk/services/test-bed

read /html/body/div[3]/main/div/div[3]/article/h1 to title

read /html/body/div[3]/main/div/div[3]/article/ul to links

write `title` to script9.txt
write `links` to script9.txt

Script 10: Get Table Data

Script 10
// Script 10: Get Table Data
//tagui script7.tag -h

// Saves table data to a csv file
// based on the table number on webpage or its XPath identifier

https://verdapress.uk/services/test-bed
table 1 to table.csv

Hint

Download project scripts

TagUI Reference

TagUI Documentation


If you require support or help check out our services page.