Monday, May 22, 2006

WinRunner FAQ

Q: Winrunner testscript for checking all the links at a time

location = 0;
set_window("YourWindow",5);

while(obj_exists((link = "{class: object,MSW_class: html_text_link,location: "
& location & "}"))== E_OK)
{
obj_highlight(link);
web_obj_get_info(link,"name",name);
web_link_valid(link,valid);
if(valid)
tl_step("Check web link",PASS,"Web link \"" & name & "\" is valid.");
else
tl_step("Check web link",FAIL,"Web link \"" & name & "\" is not valid.");
location++;
}


Q: How to write an email address validation script in TSL?

public function IsValidEMAIL(in strText)
{
auto aryEmail[], aryEmail2[], n;

n = split(strText, aryEmail, "@");
if (n != 2)
return FALSE;

# Ensure the string "@MyISP.Com" does not pass...
if (!length(aryEmail[1]))
return FALSE;

n = split(aryEmail[2], aryEmail2, ".");
if (n < 2)
return FALSE;
# Ensure the string "Recipient@." does not pass...
if (!(length(aryEmai2[1]) * length(aryEmai2[1])))
return FALSE;

return TRUE; }


Q:How do you find an object in an GUI map?

The GUI Map Editor is been provided with a Find and Show Buttons.
To find a particular object in the GUI Map file in the application, select the object and click the Show window. This blinks the selected object.
To find a particular object in a GUI Map file click the Find button, which gives the option to select the object. When the object is selected, if the object has been learned to the GUI Map file it will be focused in the GUI Map file.


Q:How WinRunner handles varying window labels?

We can handle varying window labels using regular expressions. WinRunner uses two hidden properties in order to use regular expression in an object’s physical description. These properties are regexp_label and regexp_MSW_class.
i. The regexp_label property is used for windows only. It operates behind the scenes to insert a regular expression into a window’s label description.
ii. The regexp_MSW_class property inserts a regular expression into an object’s MSW_class. It is obligatory for all types of windows and for the object class object.


Q:How do you find out which is the start up file in WinRunner?

The test script name in the Startup Test box in the Environment tab in the General Options dialog box is the start up file in WinRunner.


More ......

No comments: