Please try to use this code instead of
Dialog("Window").WinButton("OK").Click
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Const WM_COMMAND = 273 'This constant is used to indicate we are
going to interact with a Command dialog box
Public Const BM_CLICK = 245 'This constant is used to indicate we are
going to interact with a File Dialog box
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA",
micString, micString
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, "SendMessage", "user32.dll", "SendMessageA",
micHwnd, micLong, micLong, micString
HandleAlert "OK"
'*******************************************************************************************************************************************************************************************************************
'Function Name: HandleAlert
'Description: Handles the alert in QTP
' Parameters: btnClick,
'Parameters Description: btnClick - button need to be clicked
'Returns: None
'Created By : Revanth Kumar Methuku
'Creation Date Feb 22, 2010
'*******************************************************************************************************************************************************************************************************************
Function HandleAlert(btnClick)
If btnClick = "OK" Then
buttonCode = 1
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Message from webpage")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Windows Internet Explorer")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Microsoft Internet Explorer")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
ElseIf btnClick = "CANCEL" Then
buttonCode = 2
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Message from webpage")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Windows Internet Explorer")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Microsoft Internet Explorer")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)
End If
End Function
Let me know if you are successful
Thanks,
Revanth
On 15 June 2012 15:40, suman ch <[email protected]> wrote:
> It might be focus problem. Activate the Dialog before clicking button.
>
> Ex: Dialog("Window").Activate
> Dialog("Window").WinButton("OK").Click
>
> Regards,
> Suman Ch
>
>
>
> On Fri, Jun 15, 2012 at 11:50 AM, Gajendra Jain
> <[email protected]>wrote:
>
>> I am running test suite from the QC in my local machine.
>>
>> During run, my system doesn't get locked.
>>
>> But anyways if you could share the code, I will try to run that in my
>> machine.
>>
>> Thanks
>> Gajendra
>>
>>
>> On Thu, Jun 14, 2012 at 5:03 PM, Revanth <[email protected]> wrote:
>>
>>> I faced the same problem
>>>
>>> Are you trying to run the complete test suite? If Yes then, if you close
>>> the rdc or lock the computer, clicking on dialog ok and cancel doesn't work
>>> (Known Issue documented in Read me file of HP)
>>>
>>> Please let me know if it is the situation, i will share the code how i
>>> overcome this issue.
>>>
>>> Thanks,
>>> Revanth
>>>
>>> On 11 June 2012 16:43, Gajendra Jain <[email protected]> wrote:
>>>
>>>> HI
>>>>
>>>> QTP 11 is not identifying the dialog box when the script is run in a
>>>> batch from the test plan.
>>>> Where as the same object(OK, cancel button in dialog box) gets
>>>> identified when we run the script individually.
>>>>
>>>> Could you please let me know, whether there is any problem with QTP or
>>>> anything else?
>>>>
>>>> Regards,
>>>> Gajendra
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> "QTP - HP Quick Test Professional - Automated Software Testing"
>>>> group.
>>>> To post to this group, send email to [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/MercuryQTP?hl=en
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> "QTP - HP Quick Test Professional - Automated Software Testing"
>>> group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/MercuryQTP?hl=en
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> "QTP - HP Quick Test Professional - Automated Software Testing"
>> group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/MercuryQTP?hl=en
>>
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en