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: How to test to see if the window is maximized

If you want to test to see if the window is maximized here is a sample of how to code it. This code would be best used in the start up script of any automation project.
#first grab the windows handle for the netsoft elite window
win_get_info("Browser Main Window ","handle",value);
#now test to see if window can be maximized
if(win_check_info("Browser Main Window ","maximizable",FALSE)!=E_OK)
{
#Now run maximize function and pass in the handle's value
if (is_maximized(value) == E_OK)
{
report_msg("Ran Max window test and maxed the window");
win_max("Browser Main Window ");
}
else
{
report_msg("Ran Max window test and did not have to do anything");
}
}
# end of script


WinRunner: How to determine which window you are on:

Each time a new browser window appears, you need to test to make sure the correct window is activated. to do with use the following code:
#test to make sure on browser
win_check_info("Browser Main Window_1","enabled",1);
# check to make sure the menu says Menu Selection
menu = obj_check_gui("title_shad", "list5.ckl", "gui5", 5);
if (menu == 0)
report_msg("On Menu Window");
else
{
report_msg("not on right window");
texit:
}


WinRunner: How to test if a link exists and is valid

Use the web_link_valid command, then add some conditional logic to say whether or not the test passed.
# verify the link is valid
set_window("Default Menu", 1);
yes = web_link_valid("YOUR PRODUCT APPLICATION", valid);
if (yes == 0)
report_msg("link exists on page");
else
report_msg("no link");


WinRunner: How to select a link on a web page

In order to select a link, you need to use the web_link_click command.
win_activate ("Browser Main Window");
set_window ("Default Menu", 0);
web_link_click("YOUR PRODUCT APPLICATION");
web_sync(5);


WinRunner: How to check a property of an object on the web page

The most flexible and dynamic GUI check point is the Multiple Objects Check point. This feature allows you to view the objects before selecting them, and then gives you the opportunity to select with properties of the object you want to test.
Steps to Verify contents of a list box:
1. Turn on record in context sensitive mode (this will create GUI objects for you, if you try using insert function only the code will be created, and you will then have to run in update mode to generate the gui checks).
2. Select Create -> GUI Check -> Multiple Objects
3. Next the Create GUI check point window will come up
4. Press the Add button
5. Now move the cursor around the screen and select the object(s) you want to test.
6. When done selecting the objects press right mouse
7. Now you will be brought back to the Create GUI check point window. Listed in the window will be the object(s) you selected. For each object a list of properties will be selected. Using the check boxes on the left select which values you want to check. To view the content of the values, click on the < … > in the expected results.
8. By clicking on the < … > the edit check window will come up, that will allow you to edit the values.
9. When done press OK on all windows. Then the following code will be added to your script.
win_activate ("Browser Main Window_0");
win_check_gui("State Selection", "list1.ckl", "gui1", 1);
10. To modify or edit your GUI check point select Create -> Edit GUI checklist, and the Create GUI check point window will come back up.


WinRunner: Parameterization rules:

. Do not call the excel sheet default.xls, rename it the same name as your script (or calling script).
If you want the change the start row of the table change the code table_Row = 1 on the line
for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
. The c:\~\WinRunner\dat\ddt_func.ini file lists what functions will work with Data Driven testing. No web functions are listed in this file. If you want to data drive a web function you will have to added them to the file.
. Any Excel file used for data driven testing must be saved in excel format.
. The Excel Files can only have one worksheet and no formatting.
. The character length max for a number in a cell is 10 char. Anything over becomes scientific notation and does not work. There are two workarounds to this problem, option one is to use concatenation, and option two is to use a ' in the field and make the value a string.
Workaround 1:
Use the & (concatenation command to make your values larger. ) Here is a code sample: edit_set("1" & ddt_val(table,"SalesNumMax"));
Workaround 2:
In the data table, instead of typing in the number as 12345678901 type it in as '12345678901. The ' in the front of the number will make it a string (and strings char limits are 255).
. Also a field length can not start with leading 0's. To work around this, use either of the methodologies shown above.
. When defining a new table in the DataDriver Wizard, the table will not be saved if an .xls extension is not specified.
Workaround: When typing the name of a new table, set the name to have an .xls extension. If you use the Parameterize Data function, DO NOT highlight the row, just put your cursor on the space you want to over lay and it will work. If you highlight the whole row, it comes back all messed up.
Here are some steps that explain how to use the DataDriven functionality in WinRunner.
1. Record your script save it
2. Select wizard Tools -> Data Driven Wizard
3. Press Next button
4. At Use a new or existing Excel file box: Navigate to data file area and select data file or enter name for new file.
5. On Assign table name variable: Enter the name to call table in script.
6. Check off Add statements and create a data-driven test
7. Check Parameterize test by line
8. Press Next button
9. On Test Script line to parameterize: either do not replace line (if you don't want to) or select a new column. If you select a new column (you can change column name if you want.
10. Repeat for all lines that appear (this depends upon how many line you have in script.
11. When done press Finish
12. Your script will come back and it is all parameterized for you.

Here are Code:
1 table = "path to excel file";
2 rc = ddt_open(table, DDT_MODE_READ);
3 if (rc!= E_OK && rc != E_FILE_OPEN)
4 pause("Cannot open table.");
5 ddt_get_row_count(table,table_RowCount);
6 for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
7 {
8 ddt_set_row(table,table_Row);
9 edit_set("Log",ddt_val(table,"Log"));
10 obj_type("Log","");
11 edit_set("password",ddt_val(table, "password"));
12 button_press("Login");
13 }
14 ddt_close(table);
Manual
1. Create an xls file (using WinRunner's Tools -> Data Table)
2. Make the Columns names be your variable name, make the rows be your data.
3. Save the Xls file
4. At the top of your script type line 1 (take from above example) - This sets the table name for you.
5. Type lines 2 - 5 exactly - this tells the script to open the table and does error handling incase it can't open the table, and gets the count of the table
6. Now move cursor to area want to parameterize.
7 Type lines 6 - 8. If you do not want to script to start on row 1, change table_Row = (row to start on).
If you want to run numerous times then create a loop here.
8. Now move cursor to line you want to parameterize. You parameterize by replacing the value in the edit_field statement with ddt_val(table, "variable").
Before:
edit_set("log", "STORE");
After parameterization will look like:
edit_set("Log", ddt_val(table,"Log"));
9. Repeat for all lines you want to parameterize.
10. Then add the closing }.
11. Add the last line (14) to close the table.
12. Repeat steps 7 - 11 for all areas you need to parameterize in code.

ddt_func.ini file:
The Data Wizard functionality uses the ddt_func.ini file to determine which functions you can parameterize. If you run the wizard and find that a certain function does not parameterize the work around is to add the parameter to the ddt_func.ini file. Here are the steps: 1. Shut down WinRunner Application 2. Open the ddt_func.ini file located in your \~\winrunner\dat directory. 3. Add the function you want to add and the parameter of the function you want the Data wizard to change. 4. Save the file 5. Bring up WinRunner Again. 6. Your function should now work with the data wizard

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