Forum Discussion
Hi,
The general approach is the same as for any other window:
-- Examine the warning window in the Object Browser and determine its identification properties;
-- After the link is clicked, wait in a loop until either download starts or the warning window appears;
-- If the warning window appears, close it to proceed to file download;
-- In a loop wait until the file is downloaded (consider timeout in order not to stay in a loop forever if download fails for some reason).
Note: identification of the warning window (and, especially, its internal controls) may require MSAA extension to be enabled in TestComplete.
Note 2: usually, warning windows are different for different browsers.
A sample of the similar function (VBScript) to provide you with an idea:
'-----------------------------------------------------------------------------
Sub BrowserConfirmationWindowClose
Const cProcName = "BrowserConfirmationWindowClose"
Dim cProcNameMsgPrefix : cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & "(): "
Dim browser
Dim oWin
Set browser = Aliases.browser
Select Case browser.ObjectIdentifier
Case "iexplore"
Select Case browser.FileVersionInfo.MajorPart
Case 7
Case 8
Case Else
'Aliases.browser.BrowserWindow(0).Window("Frame Notification Bar", "", 1).ToolBar("Notification").Button("Close")
Set oWin = browser.BrowserWindow(0).WaitWindow("Frame Notification Bar", "", -1, 500)
If (oWin.Exists) Then
If (oWin.Visible) Then _
Call oWin.ToolBar("Notification*").Button("Close").Click
End If
End Select
Case "firefox"
Case "chrome"
Case "safari"
End Select
End Sub
'-----------------------------------------------------------------------------
Sub CheckForBrowserConfirmation
Const cProcName = "CheckForBrowserConfirmation"
Dim cProcNameMsgPrefix : cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & "(): "
Dim browser
Dim oWin, oWin2
Set browser = Aliases.browser
Select Case browser.ObjectIdentifier
Case "iexplore"
Select Case browser.FileVersionInfo.MajorPart
Case 7
Case 8
Case Else
'Aliases.browser.BrowserWindow(0).Window("Frame Notification Bar", "", 1).ToolBar("Notification").Button("Open")
Set oWin = browser.BrowserWindow(0).WaitWindow("Frame Notification Bar", "", -1, 500)
If (oWin.Exists) Then
If (oWin.Visible) Then _
Call oWin.ToolBar("Notification*").WaitButton("Open", 30000).Click
End If
End Select
Case "firefox"
Set oWin = browser.WaitWindow("MozillaDialogClass", "Opening *", -1, 500)
If (oWin.Exists) Then
Call oWin.FindChild("ObjectIdentifier", "Open", 30).Click
End If
Case "chrome"
Case "safari"
End Select
End Sub
'-----------------------------------------------------------------------------