QTP Forums

Full Version: Issues while running QTP Script in Siebel.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
(08-21-2009 10:12 AM)Saket Wrote: [ -> ]Hi Smita,

would you like to use Windows API in your script?
Try this - Paste the following code into your script or in a library file and call the function 'HandleDialog' where you want to handle the dialog

Code:
Extern.Declare micHwnd, "FindWindowEx", "user32.dll", "FindWindowExA", micHwnd, micHwnd, micString, micString
Extern.Declare micLong, "PostMessage", "user32.dll", "PostMessageA", micHwnd, micLong, micLong, micLong
Extern.Declare micLong, "GetWindow", "user32.dll", "GetWindow", micLong, micLong

Const BM_CLICK = &HF5
Const WM_SETFOCUS = &H7



Public Function HandleDialog()

    pHwnd = extern.FindWindowEx(0,0, vbNullString, "Microsoft Internet Explorer")
    'pHwnd = extern.FindWindowEx(0,0, vbNullString, "Message from webpage")
    extern.PostMessage pHwnd,WM_SETFOCUS,0,0
    If pHwnd > 0 Then
        btnHwnd = extern.FindWindowEx(pHwnd,0,"button" ,vbNullString)

        extern.PostMessage btnHwnd,WM_SETFOCUS,0,0
        wait(5)
        extern.PostMessage btnHwnd,BM_CLICK,0,0
    End If

End Function

Let me know if there is any issue

Saket -
This is a nice piece of code. I was just wondering would it not treat IE as a window since "Microsoft Internet Explorer" is the tag we are providing to search for ?

Smita -
did any of the other solutions help you so far ?
Basanth - unfortunately I dont have IE6 on my machine now, so not able to try with that. but I am sure that It will treat IE as a window because I think whenever we open an application in IE it takes the name of application as well so until unless we will not pass the whole name or in regualae expression, it will not the the IE, I think the caption comes as - '<<App Name>> - Microsoft Internet Explorer'

hope you are getting what i am trying to explain Smile
Sory Typo - Please read ' It will treat IE as a window because ' as It will not treat IE as a window because '
(08-21-2009 11:02 AM)Saket Wrote: [ -> ]Basanth - unfortunately I dont have IE6 on my machine now, so not able to try with that. but I am sure that It will treat IE as a window because I think whenever we open an application in IE it takes the name of application as well so until unless we will not pass the whole name or in regualae expression, it will not the the IE, I think the caption comes as - '<<App Name>> - Microsoft Internet Explorer'

hope you are getting what i am trying to explain Smile
Sory Typo - Please read ' It will treat IE as a window because ' as It will not treat IE as a window because '

Yeah got it. Wink I do that typo and if you dont notice it, it gives a total different meaning.Smile Well i guess the risk we have to take is that the app name is being displayed on the title which i hope every developer thinks as a basic common sense during coding Big Grin
Thanks a lot to you basanth, your last solution really worked well.

This issue got solved which was pending for very very long time.
(08-24-2009 04:06 PM)Smita Dash Wrote: [ -> ]Thanks a lot to you basanth, your last solution really worked well.

This issue got solved which was pending for very very long time.

Excellent !!!
Basanth,
You may want to write a quick explanation of your approach for everyone (like how you are activating the window , also it would be good to have a link to MSDN for the method used ). We can then stick this thread on top of sub-forums "QTP Others" and make the thread title bit more related to the question asked by OP.
[/code]Set fso = CreateObject("WScript.Shell")
While fso.AppActivate("Your Window Name") = FALSE
wscript.sleep 1000
Wend
fso.SendKeys "a", True

fso.SendKeys "N", True

wscript.sleep 7000

While fso.AppActivate ("Your Window Name") = FALSE
wscript.sleep 1000
Wend

fso.SendKeys "N", True
[code]
Ugh...I wrote a lot and everything seems to have got deleted other than the Code :-).

Okay i am going to rewrite the whole stuff.

There are several instances when QTP hangs due to a window appearing on the screen. Reasons debated being several, the core issue is derieved from the very fact about the outlook security window which appears and freezes the qtp script. To negate this situation a execution of a external vbs file which parallelly works to counter the windows presence and hence closing it through the keystrokes helps qtp to proceed further.

1. Save the above code as dialoghandler.vbs on your c:\ drive.
2. Be sure to modify the code to replace the window title or name.
3. Replace the appropriate keystrokes you need to send for the dialog. [ for eg :you may need to press "Enter" which inturn actually clicks on "OK" or "cancel" button.
4. Just before the line on QTP where the code executes and freezes QTP, enter this code,
SystemUtil.Run "C:\Windows\System32\Wscript.exe", "C:\dialoghandler.vbs"

This Solution was provided to me by Yaron Assa of the AdvancedQtp Fame.

Let me know if you have any questions.
(08-24-2009 07:44 PM)basanth27 Wrote: [ -> ][/code]Set fso = CreateObject("WScript.Shell")
While fso.AppActivate("Your Window Name") = FALSE
wscript.sleep 1000
Wend
fso.SendKeys "a", True

fso.SendKeys "N", True

wscript.sleep 7000

While fso.AppActivate ("Your Window Name") = FALSE
wscript.sleep 1000
Wend

fso.SendKeys "N", True
[code]
Ugh...I wrote a lot and everything seems to have got deleted other than the Code :-).

Okay i am going to rewrite the whole stuff.

There are several instances when QTP hangs due to a window appearing on the screen. Reasons debated being several, the core issue is derieved from the very fact about the outlook security window which appears and freezes the qtp script. To negate this situation a execution of a external vbs file which parallelly works to counter the windows presence and hence closing it through the keystrokes helps qtp to proceed further.

1. Save the above code as dialoghandler.vbs on your c:\ drive.
2. Be sure to modify the code to replace the window title or name.
3. Replace the appropriate keystrokes you need to send for the dialog. [ for eg :you may need to press "Enter" which inturn actually clicks on "OK" or "cancel" button.
4. Just before the line on QTP where the code executes and freezes QTP, enter this code,
SystemUtil.Run "C:\Windows\System32\Wscript.exe", "C:\dialoghandler.vbs"

This Solution was provided to me by Yaron Assa of the AdvancedQtp Fame.

Let me know if you have any questions.
I am not sure if this issue has been resolved. But here is another solution we tried and it works great.

Prior to the Select method, have the following code
SiebelApplication("XYZ").SetTimeOut(10)
On Error Resume Next
SiebApplication ......Select "....."
On Error Goto 0

Browser()....Dialog().Click

Thanks MV
Pages: 1 2 3
Reference URL's