IT Community - Software Programming, Web Development and Technical Support

WinRunner FAQ's

This is a discussion on WinRunner FAQ's within the Testing Tools forums, part of the Software Quality Assurance category; Posting a pass or fail message to the Test Results log: When Batch test is running, if some of atomic ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Quality Assurance > Testing Tools

Register FAQ Members List Calendar Mark Forums Read
  #241 (permalink)  
Old 12-20-2007, 01:43 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Posting a pass or fail message to the Test Results log:

When Batch test is running, if some of atomic tests is failed (exception handler has executed eval("texit (E_GENERAL_ERROR), tl_step function stops logging future events. Therefore better is using my_tl_step() function. It will log in file. It always works. E.g.

my_tl_step("People Terminate",result,Msg);



-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #242 (permalink)  
Old 12-26-2007, 02:56 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

If you want to have different code for different browser use the following function to identify the browser type:

version=GetWindowActiveBrowserVersion("spMain");

I don’t have the list of codes, but I know that 6=IE 5.5

-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #243 (permalink)  
Old 12-26-2007, 02:57 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

Samples for finding text in window:

Sometimes is necessary to check, that text doesn’t appear in window (i.e. to check delete), but function web_frame_text_exists generates an error, if text is not found, therefore text search functions are preferable:

# web_frame_get_text_count - the most preferable and the easiest way:
if(web_frame_get_text_count(frame, text, occur)!=E_STR_NOT_FOUND)
print "web_frame_get_text_count " text & " " & occur & " occurrences FOUND" ;
else
print "web_frame_get_text_count " & text & " NOT FOUND";
# web_frame_get_text - also works
if(web_frame_get_text(frame, a,text, text, 1)!=E_NOT_FOUND)
print "web_frame_get_text " text & " FOUND";
else
print "web_frame_get_text " & text & " NOT FOUND";
# web_find_text very expensive (finds graphical position of text)
web_find_text (frame, text, pos);
if (pos[0]!="")
print "web_find_text " & text & " FOUND at [" & pos[0] & "," & pos[1] & "," & pos[2] & "," & pos[3] & "]" ;
else
print "web_find_text " & text & " NOT FOUND";


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #244 (permalink)  
Old 12-26-2007, 02:58 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

Finding an object in list or table:

There are two approaches to find an object in list or table – more generic with loop and counter, and more fast, but more dependent on GUI (table description). Use one of them where it is more approprate:

# generic algorithm, don't need table, but slower and harder to get necessary object if many similar exist
i=0;
while (obj_exists("{class: push_button,MSW_class: html_push_button,html_name: View,location: "i"}")==E_OK)
i++;
button_press("{class: push_button,MSW_class: html_push_button,html_name: View,location: "i-1"}");
# get child object from table cell, fast and simple but depends on table description
tbl_get_rows_count("Table1",i);
web_obj_get_child_item("Table1","#"i, "#2","html_push_button",0,button);
button_press(button);

-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #245 (permalink)  
Old 12-26-2007, 02:59 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

Get physical description of html table from name:

If table are generated automatically (ASP, JSP), then sometimes it is necessary to get the physical description of one and to operate on it instead of logical name, which must present in GUI mapping file.

set_window(window_name, 1); # sets active window
for (i=1;i<99;i++) { # checks up to 99 tables
$description = "{class: object,MSW_class: html_table,location: " & i & "}"; # Generate description of table
; if (obj_exists(description)==E_OK) {
web_obj_get_info(description, "name", found_name); # check for name of found table
if (found_name == expected_name)
found_location = i; # This is the location, we are interested
break;
}
else break; # Exit on first object non-existence
}
final_$description = "{class: object,MSW_class: html_table,location: " & found_location & "}";
;

Find text in table column ad activate link or other item in necessary row:

tbl_get_rows_count ("table_name",rows_count);
for(i=first_row;i<=rows_count;i++) {
tbl_get_cell_data("table_name", "#"&i,"#"&column, tmp_name);
if (index(tmp_name,"text_to_find")!=0) break; # if found, break
}
web_obj_get_child_item("table_name", "#"&i,"#2", "html_text_link", 0, item); # Select link
web_link_click(item); # and click

-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #246 (permalink)  
Old 12-26-2007, 02:59 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

Operating with Dialog Windows:

Usually it is hard to get Dialog Windows by they name, therefore use function get_win_desc().


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #247 (permalink)  
Old 01-23-2008, 10:40 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

1. Validating a Basic Test:
After creating a test, validate it in the Virtual User Recorder. This enables to check it for errors before incorporating it into a scenario.

Validation Modes:
a. Debug Mode:
Test is run in a browser and full debugging capabilities are provided. At the conclusion of a test run in Debug mode a report opens detailing the results.

b. Load Mode:
Runs the test as if it were part of a load scenario in the Controller. A test that passes the Load replay will always run successfully in the Controller. At the conclusion of a test run in Load mode, details of any error are shown in the Log Viewer.


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #248 (permalink)  
Old 01-23-2008, 10:43 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Do not use report_msg as a substitute for tl_step:

Nobody wants to read every line of the test results looking for a failure. It's much easier to look for green or red. It's OK to have a tl_step failure without a tl_step pass.

Wrong:

if(win_exists("Active Information Manager",1) == 0)
{
set_window("Active Information Manager", 1);
obj_get_text("AfxWnd42", text);
my_gui_checkpoint(text,"AIM.log");
}
else
report_msg("AIM failure! Window absent at startup");

Right:

if(win_exists("Active Information Manager",1) == 0)
{
set_window("Active Information Manager", 1);
obj_get_text("AfxWnd42", text);
my_gui_checkpoint(text,"AIM.log");
}
else
tl_step("AimReportRuns",FAIL,"AIM window absent at startup");

-SHanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #249 (permalink)  
Old 01-23-2008, 10:44 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Do not use excessive wait statements. Try to use synchronization functions when waiting is required.


Wrong:

wait(40);


Right:

statusbar_wait_info("Status Bar","value","Sites processed = 20",40);


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #250 (permalink)  
Old 01-23-2008, 10:45 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Use text recognition as a last resort

Text recognition takes a lot of memory, can be unreliable, and can have varying results on different operating systems. It should therefore only be used if there is no other way to get the information from an object. Unfortunately, this is often the case, especially when the object is not recognized (class: object). In the following example, assume that "Assign Date" is class edit:


Wrong:

obj_get_text("Assign Date", text);

Right:

edit_get_text("Assign Date",text);


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #251 (permalink)  
Old 01-23-2008, 10:46 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Avoid hard coding testing environment dependencies

Do not hardcode information which my change depending on testing environment. These include installation directories, DSN names, names of database servers, database usernames, and database passwords. It's better to define these in variables at the beginning of the test, so you do not have to make multiple changes throughout the script to implement an environmental change.


Wrong:

set_window("SQL Server Login",10);
edit_set("Login ID:", "sa");
edit_type("Password:", "password");

Right:

db_username = "sa";
db_password = "password";

set_window("SQL Server Login",10);
edit_set("Login ID:", db_username);
edit_type("Password:", db_password);

Wrong (also violates coding standard 1):

invoke_application("C:\\iAvenue\\Windows\\UAdmin.e xe","","c:\\Power_db",SW_SHOW);

Right:

install_dir = "c:\\iAvenue\\Windows";

invoke_application(install_dir & "\\UAdmin.exe","",getvar("testname") & "\\..\Power_db",SW_SHOW);


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #252 (permalink)  
Old 01-23-2008, 10:46 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

Indent blocks of code for readability

Wrong:

for(counter = count - 24; counter < count - 1; counter++)
{
list_get_item("ListBox",counter,item);
str = str & item & "\r\n";
}

Right:

for(counter = count - 24; counter < count - 1; counter++)
{
list_get_item("ListBox",counter,item);
str = str & item & "\r\n";
}

Right:

for(counter = count - 24; counter < count - 1; counter++){
list_get_item("ListBox",counter,item);
str = str & item & "\r\n";
}


-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #253 (permalink)  
Old 01-23-2008, 10:49 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Post Re: WinRunner FAQ's

) No hard coded paths.

A WinRunner test should be able to be copied from one machine to another and run without any problems. Anything the test depends on (gui maps, text files, compiled modules, dll's) should be in the same parent folder as the test.

Exception:

Paths to permanent files on the K drive can be hard coded if absolutely necessary. (Warning – you may run into problems with tests running simultaneously on different machines accessing the same files on the K drive)

Wrong:

reload("C:\\WR_TESTS\\Acceptance_6\\acceptance_fun ctions");


Right:

reload(getvar("testname") & "\\..\acceptance_functions");


-SHanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #254 (permalink)  
Old 01-29-2008, 11:50 PM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Unhappy Re: WinRunner FAQ's

How to Identify 2 windows on the desktop with same name and at the same place one behind another?




-Shanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #255 (permalink)  
Old 01-30-2008, 01:22 AM
simplesabita simplesabita is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 170
simplesabita is on a distinguished road
Red face Re: WinRunner FAQ's

Hi Shanthi,

Here it goes the answer..

If the standard properties of these two windows are same then you cannot identify any window when both the windows are opened in desktop. You can identify any one of these window if there is any change in standard properties between these windows(does not matters whether it has same lable).

If u have two identical objects which has same logical name and recorder physical properties ar same,then u need to add some more properties so that wirunner identifies each window uniquely, this can be done by GUI configuration.

-Sabita
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #256 (permalink)  
Old 01-30-2008, 01:24 AM
simplesabita simplesabita is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 170
simplesabita is on a distinguished road
Default Re: WinRunner FAQ's

I want to know whether a button is pressed by the user or not. I want to use this in an if statement. Does any1 know about this?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #257 (permalink)  
Old 01-30-2008, 01:34 AM
Shanthi Shanthi is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 346
Shanthi is on a distinguished road
Default Re: WinRunner FAQ's

yes u can check the status of the button ,u need to take the info from the application and u need to compare it with the actual value.

say u have a OK button which is enabled, u need to check whether its enabled or not.

u can write a fnction

public function button_check(in object, in status)
{
auto value;

button_get_info(object,"enabled",value);

if(status==value)

{

tl_step("button status check",PASS,"button is enabled");
return E_OK;
}
else
{
tl_step("button status check",FAIL,"button is not enabled");
return E_GENERAL_ERROR;
}
}

call this function

button_check("OK","1")


-SHanthi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #258 (permalink)  
Old 09-30-2008, 04:50 AM
whisup whisup is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 2
whisup is on a distinguished road
Default Re: WinRunner FAQ's

Thanks for all your post, I have the same problem and now it has been sorted!
__________________
plastic card printing
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/testing-tools/4522-winrunner-faqs.html
Posted By For Type Date
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 11-24-2007 12:09 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Winrunner 6.0 and 7.0 vigneshgets Software Testing 1 11-12-2007 11:32 PM
Winrunner 8.X simplesabita Testing Tools 1 09-07-2007 04:01 AM
framework of winrunner simplesabita Testing Tools 1 08-22-2007 04:32 AM
Winrunner Shanthi Testing Tools 1 08-10-2007 05:55 AM
How to use sql queries in WinRunner/QTP vigneshgets Software Testing 1 05-17-2007 05:20 AM


All times are GMT -7. The time now is 07:08 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0