Click and Script Enhancements
The following section describes several enhancements that can assist you in creating your script.
Most of the features described below are enhancements to the API functions. For detailed information about the functions and their arguments, see the Function Reference or click F1 on any function.
The Web (Click & Script) functions, web_xxxx, allow you to specify conditional actions during replay. Conditions are useful, for example, if you need to check for an element and perform an action only if the element is found.
For example, suppose you perform an Internet search and you want to navigate to all of the result pages by clicking Next. Since you do not know how many result pages there will be, you need to check if there is a Next button, indicating another page, without failing the step. The following code adds a verification step with a notification—if it finds the Next button, it clicks on it.
While (web_text_link("Next", DESCRIPTION, "Text=Next", VERIFICATION, "NotFound=Notify", ACTION, "UserAction=Click", LAST) == LR_PASS);
For details about the syntax and use of the VERIFICATION section, see the Function Reference.
In web_browser steps, you can use the title verification recording option to make sure that the correct page is downloaded. You can instruct the Vuser to perform this check automatically for every step or every navigation to a new top level window.
In addition, you can manually add title verifications to your script at the desired locations, using both exact and regular expression matches.
web_browser("test_step", DESCRIPTION, ... VERIFICATION, "BrowserTitle=Title", ACTION,] , LAST);
For more information, see the Function Reference.
You can set title verification options directly from within the Recording options. For more information, see the section about recording with Click & Script.
Using text checkpoints, you can verify that a text string is displayed in the appropriate place on a Web page or application and then perform an action based on the findings. You can check that a text string exists (ContainsText),or that it does not exist (DoesNotContainText),using exact or regular expression matching.
For example, suppose a Web page displays the sentence "Flight departing from New York to San Francisco". You can create a text checkpoint that checks that the words "New York" are displayed between "Flight departing from" and "to San Francisco". (In this example, you would need to use regular expression criteria.)
To implement these checkpoints, you add the Text Check related arguments to the VERIFICATION section of the step. During replay, Vusers search the innerText of the browser's HTML document and any child frames. The NotFound argument specifies the action to take if verification fails, either because the object was not found or because the text verification failed: Error, Warning, or Notify.
You can manually add text verifications to your script for existing steps. Place the text verification after the step that generated the element.
The text validation arguments are valid for the following Action functions: web_browser, web_element, web_list, web_text_link, web_table, and web_text_area.
Note: You can only use the same type of text verification once per step (for example, ContainsText twice). If you want to check for multiple texts, separate them into several steps. You can, however, use different verifications in the same step (for example, ContainsText =; DoesNotContainText). In this case, all conditions have to be met in order for the step to pass.
In the following example, the verification arguments check that we were not directed from www.acme.com to the French version of the website, acme.com/fr.
web_browser("www.acme.com", ACTION, "Navigate=http://www.acme.com/", LAST); web_browser("Verify", VERIFICATION, "ContainsText=Go to Acme France", "DoesNotContainText=acme.com in English", LAST);
Suppose you want to click on a link which has the same name as the page title. The following example evaluates the document title and uses it in the next web_text_link function.
Suppose you want to randomly click a link that belongs to some group. For example, on egdomn.com you want to randomly select a country. Regular description matching will not allow this type of operation. However, using a custom description argument, you can identify the group with an attribute that is common to all the links in the group.
Using the custom description argument, you specify any attribute of the element, even those that are not predefined for that element. During replay, the Vuser searches for those attributes specified in the DESCRIPTION section. Replay will not fail on any unknown argument in the DESCRIPTION section.
For example, to find the following hyperlink:
<a href="yahoo.com" my_attribute="bar">Yahoo</a>
web_text_link("yahoo", DESCRIPTION, "Text=yahoo", "my_attribute=bar", LAST);
In the following example, since all the relevant links have the same class name, newmerc-left-ct, you can perform a random click using the following code:
web_text_link("Click", DESCRIPTION, "Class=newmerc-left-ct", "Ordinal=random", LAST);
The following functions do not support the custom description arguments: web_browser, web_map_area, web_radio_group, and web_reg_dialog.