hello world, TagUI!

Overview

This is our first script in TagUI!

Sample Code

//my first TagUI script!
https://google.com
enter //input[@id="lst-ib"] as google weather singapore[enter]
read //span[@id="wob_tm"] to temperature
echo "Current temperature in Singapore = " + temperature

Explanation

Line 1: The // denotes comments in TagUI.
Line 2: go to URL: https://google.com
Line 3: enter "google weather singapore" into the Google search field.
  • The [enter] at the end simulates the user pressing the "Enter" key, which will start the search.
  • In Chrome browser, right click on the Google Search Field and choose "Inspect". The Chrome Developer Tools will be displayed and you will see that the HTML of the search field is:
  • <input class="gsfi" id="lst-ib" maxlength="2048" name="q" value="" ... >
  • Hence we use the following XPath for the search field: //input[@id="lst-ib"]
Line 4: read the current temperature into the variable temperature.
  • Again, right click on the temperature and choose "Inspect". You will see that the HTML of the element that display the temperature is:
  • <span class="wob_t" id="wob_tm" style="display:inline">28</span>
  • Hence we use the following XPath for the search field: //span[@id="wob_tm"]
  • The value read is stored in the variable temperature.
Line 5: Output the temperature to the command window using the echo command.
  • Everything within the quotation marks will be output as-is.
  • The temperature without the quotation marks denotes a variable.
  • The + sign joins two strings together.

Where to go from here?

TagUI Tutorials

Comments (0)

There are no comments posted here yet

Leave your comments

Posting comment as a guest. Sign up or login to your account.
Attachments (0 / 3)
Share Your Location