TESTEVERYTHING

Monday 23 May 2011

Handle Popup Dialog window in Browser QTP

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

6 comments:

Danayya S Hiremath said...

its awesome......

TestEverything said...

Thanks for reading the blog

sumeet said...

one of the best blogs in qtp i have come across..wonderful work Rajiv..

TestEverything said...

Thanks bro.. :)

Anonymous said...

Hi Rajiv,
I am a learner, and I tried your code.but it isnot working. I did copy past, saved as a library and associated with the test. I called it from an action. qtp raised an error. Please tell me the correct procedure to test this.

san said...

How does this work do you need to make "regexpwndtitle" into a regular expression ?

Post a Comment

Which one is right ?

Translate







Tweet