Software QA FYI - SQAFYI

Mercury WinRunner FAQ

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  

WinRunner: The following script and dll provides WinRunner with perl-like regular expression search and match functions, to use with any GUI property, and add search and match functions.

By Misha Verplak
# regular expressions from DLL
extern int re_match(string str, string re, out int m_pos, out int m_len, inout string detail <252>);
extern int re_search(string str, string re, out int m_pos, out int m_len, inout string detail <252>);
public function re_func_init()
{ auto re_func_dll, html_name;
# location of dll
re_func_dll = getenv("M_ROOT") "\\arch\\rexp.dll";
# to access exported functions
load_dll(re_func_dll);
# function generator declarations
generator_add_function("re_search","Search a string for a regular expression.\n"
"Returns 0 no match, 1 found match, gets position and length.\n"
"Submatch results in 'detail', use re_get_details() or re_get_match().",5,
"search_string","type_edit","\"string to search\"",
"regular_expression","type_edit","\"regexp\"", "Out position","type_edit","position",
"Out length","type_edit","len", "Out detail","type_edit","detail");
generator_add_category("regex");
generator_add_function_to_category("regex","re_search");
generator_set_default_function("regex","re_search");

generator_add_function("re_match","Match a regular expression to a whole string.\n"
"Returns 0 no match, 1 found match, gets position and length.\n"
"Submatch results in 'detail', use re_get_details() or re_get_match().",5,
"match_string","type_edit","\"string to match\"",
"regular_expression","type_edit","\"regexp\"", "Out position","type_edit","position",
"Out length","type_edit","len", "Out detail","type_edit","detail");
generator_add_function_to_category("regex","re_match");

generator_add_function("re_get_detail","Get the (sub)match position and length from the detail.\n"
"Typically used after re_search() or re_match()\nsubmatch can be 0 for whole match",6,
"detail","type_edit","detail", "submatch","type_edit","0", "Out nsubs","type_edit","nsubs",
"Out line","type_edit","line", "Out position","type_edit","position", "Out length","type_edit","len");
generator_add_function_to_category("regex","re_get_detail");

generator_add_function("re_get_match","Get the (sub)matched string from the detail.\n"
"Typically used after re_search() or re_match()\nsubmatch can be 0 for whole match",4,
"original_string","type_edit","orig_str", "detail","type_edit","detail",
"submatch","type_edit","0", "Out match_str","type_edit","match_str");
generator_add_function_to_category("regex","re_get_match");

generator_add_function("re_print_detail","Print the re match details to the debug window.\n"
"Typically used after re_search() or re_match().",1, "detail","type_edit","detail");
generator_add_function_to_category("regex","re_print_detail");

generator_add_function("matche","Replacement for the builtin match() function.",2,
"match_string","type_edit","\"string to match\"", "regular_expression","type_edit","\"regexp\"");
generator_add_function_to_category("string","matche");
generator_add_function_to_category("regex","matche");
generator_add_function("match","Do not use this function. Use matche() instead.",0);
}

# replacement for the builtin match() function
public function matche(search_string, regexp)
{
extern RSTART, RLENGTH;
auto rc, m_pos, m_len, detail;
if(re_search(search_string, regexp, m_pos, m_len, detail))
{
rc = m_pos+1;
RSTART = m_pos+1;
RLENGTH = m_len;
}
else
{
rc = 0;
RSTART = 0;
RLENGTH = 0;
}
return rc;
}

# internal function to decode detail from DLL
function _detail_decode(detail, position, nbytes)
{
auto v, v_hi;
v = int(ascii(substr(detail, position, 1))/2);
if(nbytes == 2)
{
v_hi = int(ascii(substr(detail, position+1, 1))/2);
v += v_hi*256;
}
return v;
}

# dump the detail to WinRunner's debug window
#
# structure of the detail string:
# (1 byte ) size of this detail, ie. number of submatches + 1
# (2 bytes) line number where match occurred, counting from 1
# [(2 bytes) position of (sub)match, 0-th submatch is whole match
# [(2 bytes) length of (sub)match
# [--------- repeated to a maximum of 50 submatches ---]
#
public function re_print_detail(detail)
{
auto size, line, i, pos, len, s;

size = _detail_decode(detail, 1, 1);
print "size " size;
if (size == 0) return E_OK;
print "submatches " (size-1);
line = _detail_decode(detail, 2, 2);
print "line " line;

for (s=0; s<size; s++)
{
pos = _detail_decode(detail, s*4+4, 2);
len = _detail_decode(detail, s*4+6, 2);
print "sub(" s ") pos: " pos " len: " len;
}
return E_OK;
}

# get the (sub)match position and length from the detail
public function re_get_detail(in detail, in submatch, out nsubs, out line, out position, out len)
{
auto size;

nsubs = 0;
position = 0;
len = 0;
line = 0;

size = _detail_decode(detail, 1, 1);
if (size == 0) return E_NOT_FOUND;
nsubs = size-1;
if (submatch < 0) return E_OUT_OF_RANGE;
if (submatch+1 > size) return E_OUT_OF_RANGE;

line = _detail_decode(detail, 2, 2);
position = _detail_decode(detail, submatch*4+4, 2);
len = _detail_decode(detail, submatch*4+6, 2);
return E_OK;
}

# get the (sub)matched string from the detail
public function re_get_match(in orig_str, in detail, in submatch, out match_str)
{
auto rc, nsubs, position, len, line;

match_str = "";

rc = re_get_detail(detail, submatch, nsubs, line, position, len);
if (rc != E_OK) return rc;

match_str = substr(orig_str, position+1, len);
return E_OK;
}


Q: Online Vs Batch Execution - Functions & Compiled Modules - Wild Card Characters
. Every time there is a change in the Application Object I need to change the Object name and rerun the Test Script with a new object Name. Any suggestions on it.?

If there is a minimal change in the application Object then it is better to wild card the Object properties


Q:Coming up soon for the following Questions. If you know the answers, please email to us !

How do you call a function from external libraries (dll).
What is the purpose of load_dll?
How do you load and unload external libraries?
How do you declare external functions in TSL?
How do you call windows APIs, explain with an example?
What is the purpose of step, step into, step out, step to cursor commands for debugging your script?
How do you update your expected results?
How do you run your script with multiple sets of expected results?
How do you view and evaluate test results for various check points?
How do you view the results of file comparison?
What is the purpose of Wdiff utility?
What are batch tests and how do you create and run batch tests ?
How do you store and view batch test results?
How do you execute your tests from windows run command?
Explain different command line options?
What TSL function you will use to pause your script?
What is the purpose of setting a break point?
What is a watch list?
During debugging how do you monitor the value of the variables?
Describe the process of planning a test in WinRunner?
How do you record a new script?
Can you e-mail a WinRunner script?
How can a person run a previously saved WinRunner script?
How can you synchronize WinRunner scripts?
What is a GUI map? How does it work?
How can you verify application behavior?
Explain in detail how WinRunner checkpoints work. What are standard checkpoints?
What is a data-driven test? What are the benefits of a data-driven test?
How do you modify logical names on GUI map?
Why would you use batch testing under WinRunner? Explain advantages and disadvantages. Give an example of one project where you used batch testing.
How do you pass parameter values between the tests? typically learns all the objects in the window else we will identifying those object, which are to be learned in a window, since we will be working with only those objects while creating scripts.
Have you used WinRunner Recovery Manager?
What is an exception handler? Wny would you define one in WinRunner?
We’re testing an application that returns a graphical object (i.e., a map) as a result of the user query. Explain how you’d teach WinRunner to recognize and analyze the returned object.
What is a TSL? Write a simple script in TSL.

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  

Mercury WinRunner FAQ