Wednesday, March 5, 2008

Getting Link count in Winrunner

I used to write hardcore code for Automation. I had a situation like, the script has to find searched items and it has to click on particular search item. Also I need to test pagination. The search results are dynamic and I need to select the items as well as need to verify the pagination links.

The following TSL snippet finds the number of links and number of rows in a given table.



public aRowCount, aColCount;
public aCell;
public aRow, aCol;
public aTemp;
public aItem, ar, ac;

public alinkcount, alinkrow;
public aout, atext;
public areturn;

# Browser Main Window
win_activate ("Browser Main Window");

# Search Items
set_window ("Search Items", 2);
wait(5);

tbl_get_rows_count("Link No", aRowCount);
tbl_get_cols_count("Link No", aColCount);

report_msg (aRowCount & " is row count");
report_msg (aColCount & " is col count");

alinkrow = 0;
alinkcount =0;
for (arow=1;arow<= aRowCount; arow++) {
web_obj_get_child_item( "Link No", arow, 1, "html_text_link", 0, aout);

report_msg (aout & " -link description");
if (length(aout) !=0 ) {
alinkcount = alinkcount + 1;
#web_tbl_get_cell_data("Link No",arow,aColCount,0,atext,areturn);
web_obj_get_child_item( "Link No", arow, aColCount, "",0 , atext);
report_msg(atext & " text in the cells");
if (length(atext) !=0 ) {
alinkrow = alinkrow + 1;
}
report_msg(alinkcount & " - total no of links in the table.");
report_msg(alinkrow & " - total no of links having full rows.");
}
}

pause(alinkcount & " - total no of links in the table.");
pause(alinkrow & " - total no of links having full rows.");

No comments: