Showing posts with label dynamicObjects. Show all posts
Showing posts with label dynamicObjects. Show all posts

Thursday, June 5, 2008

QTP - Handling Dynamic objects

Most of the QTP (Quick Test Professional) users are using playback methods to develop the scripts. Here I have given a code snippet to handle dynamic objects. You can put the object physical description directly. You can develop the script with Object Repository.

Code: Login for Mercury Flight

Dialog("nativeclass:=#32770","text:=Login").Activate Dialog("nativeclass:=#32770","text:=Login").WinEdit("nativeclass:=Edit","attached text:=Agent Name:").Set "tester1" Dialog("nativeclass:=#32770","text:=Login").WinEdit("nativeclass:=Edit","attached text:=Password:").Set "mercury" Call wait(2) Dialog("nativeclass:=#32770","text:=Login").WinButton("nativeclass:=Button","text:=OK").Click

Code: Browser certification dialog
If Browser("name:=Certificate Error: Navigation Blocked").Page("title:=Certificate Error: Navigation Blocked").Exist(0) Then ' To DO End If

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); } }