Wednesday, May 21, 2008

Winrunner - Handling Dynamic objects

Most of the Winrunner users are using playback methods to develop the scripts. Here I have given two code snippets to handle dynamic objects.

Code: To find Image

public function SetToSearchPage() { web_sync(200); set_window("{class: window, MSW_class: html_frame,active:1}",60); web_image_click("{class: object,MSW_class: html_rect,html_name: \"search_gnav.gif\"}", 0, 0); web_sync(250); } #End of SetToSearchPage()

Code: To find correct Window, after clicking a link
public function SetTitle() { set_window("{class: window, MSW_class: html_frame,active:1}",20); win_get_info("{class: window, MSW_class: html_frame,active:1}","html_name", sWinTitle); #report_msg("RE Source Page Title is " & sWinTitle); if (index(sWinTitle, "Users") != 0) { set_window("My Users",40); #report_msg("My Users page has been identified"); } else if (index(sWinTitle, "Group") != 0) { set_window("Group",20); #report_msg("Group page has been identified"); } else if (index(sWinTitle, "View Agenda") != 0) { set_window("View Agenda",30); #report_msg("View Agenda page has been identified"); }else { report_msg("Couldn't find the window in GUI MAP is " & sWinTitle); } }

No comments: