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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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 ![]() |
| Sponsored Links |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| ) 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 ![]() |
| |||
| 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 ![]() |
| |||
| 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 ![]() |
| |||
| Thanks for all your post, I have the same problem and now it has been sorted!
__________________ plastic card printing |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |