SmartTag Workbench Reference

SmartTags are one of the unique features of Appvance IQ, SmartTags are collection of objects and their properties. This collection contains key-value pairs; the key being a logical name identifying the set of objects, and the value contains unique objects properties (ex: Valid HTML tags, SmartTag Type, Rules) that are used to identify the object on the web page.

One of the main burdens of an automated UI test script is the amount of maintenance needed when object properties change within the application under test. A very common way of minimizing the time it takes to update your automated test scripts is the use of a SmartTags Library. A basic SmartTag library can be implemented as a collection of key-value pairs, with the key being a logical name identifying the object and the value containing unique objects properties used to identify the object on a screen. This can be used in Test Designer scripting, JS scripting, and also during Appvance AI scans as Appvance AI supports creating application AISG using the SmartTag Library created.

For information on SmartTags for testing mobile applications, see SmartTag Workbench for Mobile Testing.

Accessing the SmartTag Workbench

In AIQ navigate to Web Testing > SmartTag Workbench.

SmartTag Summary Tab

The summary tab gives the summary of all defined SmartTags, actions, extractors, and validations.

SmartTag UI

The SmartTag Library tab allows you to create and configure SmartTags to be used for Test Designer or JS or Creating AISG more quickly. This is the place to edit your .json configuration files for the SmartTag library. The SmartTag Library tab allows to create, edit and delete SmartTags. This is a .json file. Will have .stags as the extension.

Creating a new SmartTag

To create a new SmartTag, simply fill all of the required input fields of the form and then click the "Add" button located at the top right of the container window. Make sure to fill up the following required inputs to be able to add a new SmartTag:

All the other inputs and data of the form are optional based on your needs, such as the rules, however, to create a new SmartTag you will always be required to provide the above input data. If you have selected a SmartTag from the "SmartTags List" selector and you want to create a new SmartTag, click the "SmartTags List" selector and select the first option called "Create New SmartTag", this will reset the SmartTags form and allow you to create a new SmartTag from scratch.

Manage Valid HTML Tags

The list of valid HTML tags is a static list of elements referenced from W3School's valid HTML tags list. However, if you need to add a custom HTML tag, you can do so by clicking the plus sign ("+") located beside the valid HTML tags selector label. This will prompt a modal window where you can type in the custom HTML tag to be added to the list of valid HTML tags of the current context.

You must follow the W3C Custom Elements standard for custom HTML tags such as hyphenation to add a valid HTML tag.

SmartTag Description

SmartTag descriptions can be used to provide meaningful descriptions for the SmartTags created that way it will help others in the team to check back on those descriptions to understand the SmartTags better.

Manage SmartTag Type

The SmartTag Type selector allows selecting the type of SmartTag you want to configure, based on the selected SmartTag Type, the available methods of the Methods and Actions table will toggle, each of the rule types have their own set of methods associated with. By default, when you are creating a new SmartTag or resetting the SmartTag form, the SmartTag type "Prop" will be selected. Once you have selected the desired SmartTag type, you can bind existing Actions to the available methods, all of the created actions so far in the current context will be available in the methods Action selectors at the Methods & Actions table at the bottom of the SmartTag container window.

Here's the list of methods linked to each of the available SmartTag types:

Manage SmartTag Rules

To add rules to your SmartTag, simply click the "Add Rule" button located under the "Rules" section, this will automatically add a new rule to the SmartTag, you will see the default rule type input fields displayed, these inputs will change depending on the rule type selected, meaning that based on the selected rule type you will be given a different kind of inputs and options to configure the SmartTag rule properly. Here's the list of available rule types and their corresponding input fields and restrictions:

To change a Rule Weight you can interact with the "Importance" slider of each rule container, the slider label will dynamically change based on the slider value so you can know exactly which is the rule weight.

To Remove a Rule simply click the "Remove" button located at the rightmost of the rule container.

Updating a SmartTag

File > Save and File > Save As can be used to save the modified changes.

To Remove a SmartTag, select a SmartTag from the "SmartTags List" selector and click the "Remove" button and click save.

SmartTags can be duplicated using the Duplicate button copying all the same contents and it will add a "SmartTagName-copy" and you can use the SmartTags to change or modify the SmartTags.

Actions Tab UI

Actions are used when you want to override the default behavior of a SmartTag.

For example, navigation's default action would be CLICK

if you need to change the default action, so if you need to click a specific area instead of a full click, a custom action could be created to perform this, and always remember to assign the action that was created in the Actions tab.

Actions tab allows you to create and configure Actions to the current context that can be bound with the SmartTag methods at the Methods & Actions table of the SmartTags Library tab.

You must use JQuery or JavaScript methods on the Action tab. Commands documented in Test Designer JS Commands Reference are not valid in the Actions Tab. However, those commands can be used in the Validations tab.

To create a new Action, type in the action name and the corresponding JavaScript function string and click the "Add" button located at the top right corner of the Actions tab container window. Make sure to fill up the following required inputs to be able to add a new action:

Once you have added the Action, it will be available at the Actions selectors of the Methods & Actions table of the SmartTag tab. If you have selected an Action from the "Actions List" and you need to create a new SmartTag, click the "Actions List" selector and select the "Create New Action" option, this will reset the Actions form and allow you to create a new Action.

/** You can create custom actions for SmartTags here.

*

*

**/

The array hint field is optional.

To update an Action is the same as the SmartTags Library tab functionality, you first have to select an Action from the "Actions List", modify the configuration as required, and then click the "Update" button.

To Remove an Action, select the action from the "Actions List" and then click the "Remove" button.

Example:

React Selects

Suppose there is a control that behaves like a Select, Drop-Down list, or Combo box but its HTML structure does not follow the standard, select, and option tags, but instead uses nested div tags. A Select type SmartTag allows the following interactions or functions: show values, get all values, get the selected value, and set value. Since the control does not follow the standard, the default implementation for the functions of Select type SmartTags will not work. Therefore, a custom implementation for each function must be provided.

Notice the getValue, getSelectValues and setSelected functions are bound to custom functions

Custom implementation for getValue which is set to use reactGetSelectValue

Post Actions & Previous Actions

Post Actions & Previous Actions selectors have linked with the "Actions List" selector, meaning that whenever you create or delete an action, this change will take place at all of the form selectors. These selectors allow you to bind multiple posts and previous actions to the current action in scope previous actions will be executed before the current action, and post actions will be executed after the current action.

JavaScript Function String

As the name suggests, a string representing a JavaScript function, this field is a JavaScript editor embedded in the UI that allows you to edit the JavaScript code professionally, providing coding tools such as code highlight, auto-close brackets, line numbers, and so on. It's important to notice that you must not include the function declaration, only the function body, this is part of Create AISG implementation under the hood, you must only code the JavaScript function body.

Note: All the SmartTags have getName which gets the accessors, we could override the getname so that the string that we get is not ambiguous for the Test Designer.

Extractors

Extractors are a type of validation that allows you to extract data from SmartTags.

The extraction process can occur before a SmartTag is processed or after a SmartTag is processed (Processing means the execution of the SmartTags)

You can extract many types of data, like the text of a SmartTag, the id of a SmartTag, various attributes of a SmartTag by providing the attribute name, you can also extract XPath's data by using xpath expressions.

Following are the ones that we could extract.

You can also provide customized JS code that allows you to extract many different elements from the whole page.

All the data that you extract are stored in a variable using the variable name.

As already mentioned there are pre and post actions:

An example of a pre-action could be a link where you need to get the text and store that value to be used for further processing or further validations.

Post Action extractors are something that you could store in a setValue, and after setting the value you could validate what was set as the input for those accessors using Post extractions.

You could also use JS code like the one below:

/**You can add JS code here.

**/

Examples of Pre-Action Extractor and a Post-Action Extractor below using Text:

Validations

Validations allow the extraction of data from a SmartTag and compare this data before or after a SmartTag is processed against a target that can be a variable from a previously executed Extractor or a valid JavaScript expression or a value.

Comparisons can be:

The importance of having a validator is that they have the flexibility of choosing different kinds of assertions compared to auto-validations before or after a SmartTag is executed.

As Extractors, you could choose the validators to be executed pre or post after a SmartTag is processed.

Different types of Validations are supported on:

Expected Value (JS Code): Expected string or the expected value to be entered.

Examples:

validating numbers - 257

validating text - "helloworld"

validating true/false - true or false values

We could also provide functions like - parseint(23)

parsestring("string").uppercase(); etc

Also, we could use the extractors to validate by invoking the defined extractors in the extractors tab just by using $ Symbol.

Hitting $ will invoke all the defined extractors from the extractors tab.

Some Examples Below:

Validation with Greater or Equal with Text Type and an Expected number value.

Validation with Contains Operator with Text Type and Expected string value.

This is an example showing invoking an Extractor using the $ symbol.

Other Validations

Other Validations allow determining the existence of a value or element after a SmartTag is processed. Before a SmartTag is processed, data is extracted from a SmartTag or the value of a previously executed Extractor or a specific JavaScript expression or value is loaded. After a SmartTag is processed, the value or the element is checked for its existence.

These validations always extract data from a SmartTag and after a SmartTag is processed, we validate the data against the resulting page or the specific element of the page.

The only assertion that we could do with other Validations is CONTAINS and DOES NOT CONTAIN.

This validation happens always after a SmartTag is processed.

Different Types supported:

Targets:

Some examples are below:

Type of Static Text and with expected text value targeting the whole page.

Type of Element Exist and provides the Locator value:

Note: The locator value is something that looks like the accessors from the Test Designer script.

Given this element: Login Button

<a id="login_link_id" name="login_name">Login</a>

Valid Locators can be:

link("/login")

link("Login")

link("login_name")

link(1)

Can also use CSS and XPath locators like:

byXPath('//*[text()="Login"]')

byCss("#taxonomies > div:nth-child(2) > a:nth-child(1)")

Native element types can be

link("")

textbox("")

emailbox("")

password("")

textarea("")

button("")

reset("")

span("")

submit("")

select("")

radio("")

checkbox("")

Type of Static Text expecting a string value from a Locator Target providing the Locator Value:

Type of Static Text expecting a string value (Extracted String value) from the whole page:

Note: When running designer scripts, you would notice that the validations would be performed both pre and post-validations.

Test Designer logs example:

Evaluating PreAction Validation: HasButtonNewLookUp for SmartTag: shopThisStore

Validation succeeds.

Validations have both pre and post-sections. Generally, pre section will always be successful and the post-section shall pass or fail depending on the assertion.

Pre section defines a variable with the value:

The post section performs the assertion based on the option selected in the Target field:

Settings

Settings are the most simple screen of the SmartTag UI, its purpose so far it's only to configure the SmartTag Rules Threshold, there's only a Slider control that allows you to change this threshold, by default it's 0.75. The range of this slider is from 0.0 to 1.0.

Files Management

The SmartTags UI allows you to handle SmartTags configuration files, these are JSON files (.json extension) that contain a valid SmartTags configuration JSON. The file manager window is available through the "File" drop-down located at the leftmost top corner.

These are the available options:

It is worth mentioning that the SmartTag UI will let you know when you have modified and opened the file and the changes have not been saved. When you open a file, the UI will display the file name right next to the "File" option of the file manager, if the file name label is in green color, it means that the file has not been modified since the last save (or not modified when opened), if the file name label is on orange color, it means that the file content has been modified but not yet persisted to disk, meaning that in-memory changes have not been saved to the file. To save the changes, use the "Save" option of the file manager.

SmartTag creation with an example application

In this section, we shall learn about the following:

Valid HTML Tags

SmartTag Types

Scan Types

SmartTag Rules

Navigate to SmartTag Workbench under Record and click File > New.

The first step is to fill up the SmartTag name, fill up the SmartTag name with meaningful names according to the usage, for example, Left_Menu_Items, Credentials, Top_Links are some valid names.

Valid HTML Tags

As we all know, everything you do on a web page is using tags. The basic format of a tag is this:

<TAG> (something) </TAG>

For example, say I want to get a header, like the one above. Well, the code for that header is:

<H1>Tags: What are they? How do they work?</H1>

Notice that the tag begins with: <H1> and ends with: </H1>. This is an important aspect of tags. Almost all begin AND end.

Some valid HTML tags are defined at: HTML Document Type

Valid HTML Tag selection depends on the element that we are looking at, To see tags on the web page, right-click the web page or the target element and select Inspect as shown below.

You could also notice a + icon next to Valid HTML Tags (+), it can be used to add any new custom HTML Tag Name to the default list from your application

SmartTag Types

A SmartTag can be of different types:

So depending on the element that you are looking for, a SmartTag Type should be chosen, for the example that we were working on, Navigation is the SmartTag Type that should be chosen (For the Home button) which navigates to a different page.

Scan Types

Scan Types are mostly used for scans that we perform in the AISG of the application creation.

Below are the 3 options available.

Once per app:

Check this option, If many navigation actions are redirecting to the same state, this option will consolidate them into just one for the entire site this strategy will reduce the scanning time and final file size as well.

Once per page:

Checking this option would make sense in cases such as a table containing details where all the SmartTags are mostly similar, AISG scan will process just the first occurrence by adding the action with the $SmartTag Name, this new capability will improve the AISG scan process and not repeating the same actions on that page.

Singleton:

This option is used for elements that only appear one time on the page.

SmartTag Rules

The available SmartTag rule types and short descriptive take some examples for each of the SmartTag rule types that are available so it is easy to understand.

For example, want to create a SmartTag for the "Next" button; select containsText and enter the text.

For example, to create a childTag as a rule for the below-highlighted element, use the rule as mentioned:

Try SmartTags in JavaScript/Test Designer

Now we know how to create SmartTag for different elements of the web page and other uses, now it is time to create some JS scripts using those SmartTags that we created.

For the application, http://demosite.appvance.com , we created 2 SmartTags for the products and the Shop by Brands left menu as highlighted below.

SmartTags created are shown below:

Useful AISG custom action examples

  1. GetName Custom Actions

    Get element text including the text of its children nodes.

    return ds$(element).text();

  2. Get only the current node element text.

    This action does return the current element node text without adding the text of its children nodes. If you apply this to a SmartTag that targets a span(“Yes“), this will make sure your SmartTag only focuses on the actual span that has the “Yes” text and not on its span’s parents.

    return ds$(element)
                    
    .clone() //clone the element
                    
    .children() //select all the children
                    
    .remove() //remove all the children
                    
    .end() //again go back to selected element
                    
    .text();
  3. Get the element name from one of the element’s attributes

    The following template can be used to set a general getName function that checks for an attribute to get its value, but if it does not have that attribute then it tries with another one. Modifying the code can change the order in which the attributes get fetched or add more attributes.

    var htmlElement = ds$(element);
                    
    var name = htmlElement.attr('id');
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    if (name === "") {
                    
    name = htmlElement.attr("value");
                    
    }
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    if (name === "") {
                    
    name = htmlElement.attr("name");
                    
    }
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    if (name === "") {
                    
    name = htmlElement.attr("placeholder");
                    
    }
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    if (name === "") {
                    
    name = htmlElement.attr("data-ref");
                    
    }
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    if (name === "") {
                    
    name = htmlElement.text();
                    
    }
                    
    if (typeof name === 'undefined') {
                    
    name = "";
                    
    }
                    
    return name.trim();
                    
  4. Set Value

    return ds$(element).val(params);

  5. Set Value and Enter

    return _ds.setValue(element, params + '{{ENTER}}');

  6. Do a fake MouseOver ( used for some menus)

    ds$(element).parent().find('div > ul').show();

    // where there is a div, and it has hidden child ul

  7. Get Element from a Custom Select ( For application based on complex frameworks)

    // This is an example using bootStrap

    // array hint should be defined as "array" (without quotation marks)

    var selectValues = [];

    ds$(element).find('a').each(function(idx, theElement){

    selectValues.push($(theElement).text().replace(/\n|\r/g, "").trim());

    });

    return selectValues;

  8. Set Select Element from a Custom Select ( For application based on complex frameworks)

    // This is an example using bootStrap
                    
    // array hint should be defined as "[]" (without quotation marks)
                    
    var found = false;
                    
    // params
                    
    ds$(element).find('a').each(function(idx, theElement){
                    
    var theElementText = ds$(theElement).text().replace(/\n|\r/g, "").trim();
                    
    if (params === theElementText && !found){
                    
    found = true;
                    
    //theElement.click(); // method 1
                    
    //ds$(theElement).click(); // method 2
                    
    // _ds.click(element); // method 3
                    
    }
                    
    });
                    
    return found;
                    
  9. Click to Show the list of elements inside a Custom Select (For applications based on complex frameworks)

    return ds$(element).click();

  10. Remove any new line character from the returned variable, in this case is "name"

    When creating SmartTag libraries, for the case of returning a name for SmartTags, please include this in the return ( if needed, otherwise please skip it):

    return name.trim().replace(/(\\r\\n|\\n|\\r)/g,\"\");
    var name = ds$(element).text();
                    
    if (name === ""){
                    
    if (ds$(element).hasAttr('data-component-id')){
                    
    name = ds$(element).attr('data-component-id');
                    
    }
                    
    if (ds$(element).hasAttr('id')){
                    
    name = ds$(element).attr('id');
                    
    }
                    
    }
                    
    if (typeof name !== 'string') {
                    
    name = "";
                    
    }
                    
    return name.trim().replace(/(\r\n|\n|\r)/g,"");

Last updated: March 18, 2024

If you have any feedback on this topic, please contact us at documentation@appvance.ai


Revision #8
Created 2026-07-31 15:08:48 UTC by Admin
Updated 2026-11-17 21:56:32 UTC by AI_Mananger