WORKING WITH QTP

TestEveryThinG

Handle popup window QTP VB

Posted by rajivkumarnandvani on April 11, 2009

REM *************************************************************************
REM  Function  fn_GetPopupMessageText() This function Get the lable textmessage from Popup Dialog window  in Browser page
REM  and enter the label text in Result Excel Sheet
REM Note Dialog Window Must be child of  Parent object

REM  Input              := None
REM  Output(ReturnType) := None
REM  Created:    11/April/2009    Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY

REM *************************************************************************

Call fn_GetPopupMessageText()
Public function fn_GetPopupMessageText()
Set objStaticText =Description.Create()
objStaticText(“nativeclass”).value =”Static”
objStaticText(“text”).value =”.*[a-z].*”
Set objWinbutton =Description.Create()
objWinbutton(“micclass”).value =”WinButton”
If Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).Exist(2) then
Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).Activate
set objStaticText = Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).ChildObjects(objStaticText)
For i=0 to objStaticText.count-1
sDescription =objStaticText(i).GetVisibleText(-1,-1,-1,-1)
Next
set objWinbutton = Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).ChildObjects(objWinbutton)
For i=0 to objWinbutton.count-1
objWinbutton(i).click
Exit for
Next
fn_GetPopupMessageText = sDescription
End if
End Function

Public function fn_GetPopupMessageText()
Set objStaticText =Description.Create()
objStaticText(“nativeclass”).value =”Static”
objStaticText(“text”).value =”.*[a-z].*”
Set objWinbutton =Description.Create()
objWinbutton(“micclass”).value =”WinButton”
If Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).Exist(2) then
Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).Activate
set objStaticText = Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).ChildObjects(objStaticText)
For i=0 to objStaticText.count-1
sDescription =objStaticText(i).GetVisibleText(-1,-1,-1,-1)
Next
set objWinbutton = Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).ChildObjects(objWinbutton)
For i=0 to objWinbutton.count-1
objWinbutton(i).click
Exit for
Next

fn_GetPopupMessageText = sDescription
End if

End Function

Advertisements

One Response to “Handle popup window QTP VB”

  1. Anonymous said

    Here’s another way:
    dim ieText
    ieText = Dialog(“text:=Win.*”).getVisibleText ‘gets all text
    print “ieText(” & ieText & “)” ‘display text
    Dialog(“text:=Win.*”).WinButton(“text:=OK”).Click ‘press ‘OK’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: