Hi,
The following code worked for me for IE, FF and Chrome (and Safari, IIRC).
DirectUIHWND' and '#32768' must be added and enabled in the project Properties | Open Applications |MSAA.
Also dlgInternetExplorer namemapping object was mapped using conditional mapping with 'WndClass Equals #32770 AND WndCaption Does Not Equal View Downloads* AND Visible Equals True' condition.
Hope it will help.
'-----------------------------------------------------------------------------
' Returns BrowserWindow object that corresponds to the given page object
' From: http://smartbear.com/forums/f75/t83264/how-to-match-a-page-object-to-its-browserwindow
Function BrowserWindowByPageGet(ByRef page)
Dim title
Dim wnd
Set wnd = Utils.CreateStubObject
If (Not IsNull(page)) Then
If (0 = aqString.Compare(page.ObjectType, "Page", False)) Then
title = page.contentDocument.title
Set wnd = page.Parent.FindChild("WndCaption", title & "*")
If (Not wnd.Exists) Then
Set wnd = page.Parent.FindChild("WndCaption", Project.Variables.pvtBaseURL)
End If
End If
End If
Set BrowserWindowByPageGet = wnd
End Function
'-----------------------------------------------------------------------------
Sub SystemDialogFileSave(ByVal strValue)
Dim browser
Dim dlgChooseFile
Set browser = Aliases.browser
Set dlgChooseFile = browser.dlgInternetExplorer
If (Not dlgChooseFile.Exists) Then
If ("safari" = browser.ObjectIdentifier) Then
Set dlgChooseFile = browser
Else
Set dlgChooseFile = GetPage().Parent
End If
dlgChooseFile.Refresh
Set dlgChooseFile = dlgChooseFile.WaitWindow("#32770", "*", -1, Project.Variables.pvtPageTimeout)
End If
If (aqObject.IsSupported(dlgChooseFile, "SaveFile")) Then
Call dlgChooseFile.SaveFile(strValue)
Else
Call Log.Warning("SaveFile method is not supported for the window from the attached image. Applying workaround approach", _
dlgChooseFile.FullName, , , dlgChooseFile.Picture)
Call dlgChooseFile.FindChild("WndClass", "Edit", 30).SetText(strValue)
Call dlgChooseFile.FindChild(Array("WndClass", "WndCaption"), Array("Button", "*Save"), 30).Click
End If
' Call WaitForFileIsSaved(strValue, 120)
End Sub
'-----------------------------------------------------------------------------
Function SystemDialogFileSaveHandle(ByVal strFileFullName)
Dim browser
Dim UploadFileWindow
Dim button, button2
Dim tmpControl
Dim FileName, FullFileName
SystemDialogFileSaveHandle = Empty
' handle notification bar window
' For cross-browser specifics:
' http://support.smartbear.com/articles/testcomplete/cross-browser-testing/
' http://smartbear.com/forums/f75/t76579/click-on-short-time-pop-window-(e-g-ie9-noti/
' http://smartbear.com/forums/f75/t60772/ie-8-file-download-box-save-button-not-gettin/
' http://smartbear.com/forums/f75/t60730/ie-8-save-button-is-visible-on-screen-but-vi/
Set browser = Aliases.browser
Select Case browser.ObjectIdentifier
Case "iexplore"
Select Case browser.FileVersionInfo.MajorPart
Case 7
Case 8
Case Else
Set UploadFileWindow = BrowserWindowByPageGet(GetPage()).FindChild("ObjectIdentifier", "Notification*", 30)
FileName = ""
With Project.Variables.pvtRe
.Expression = "(?g).+ (\w+\.\w+) \(.+"
If (.Exec(UploadFileWindow.Text("Notification bar Text").Value)) Then
FileName = .Match(1)
End If
End With
Set button = UploadFileWindow.FindChild( _
Array("ObjectType", "ObjectIdentifier"), Array("SplitButton", "Save"), 30)
Set button2 = button.FindChild("ObjectType", "DropDownButton", 30)
button2.Click
browser.Popup("Context").MenuItem("Save as").Click
End Select
Case "firefox"
Set UploadFileWindow = browser.WaitAliasChild("MozillaDialog", 30000)
Set button = UploadFileWindow.FindChild( _
Array("ObjectType", "ObjectIdentifier"), Array("radio", "save"), 30)
button.Click
FileName = UploadFileWindow.FindChild( _
Array("ObjectType", "ObjectIdentifier"), Array("description", "location"), 30).tooltipText
Set button = UploadFileWindow.FindChild( _
Array("ObjectType", "ObjectIdentifier"), Array("button", "OK"), 30)
Call button.WaitProperty("Enabled", True, Project.Variables.pvtPageTimeout)
button.Click
Case "chrome"
Set UploadFileWindow = browser.FindChild("WndClass", "#32770", 30)
FileName = UploadFileWindow.FindChild("WndClass", "Edit", 30).wText
End Select ' browser.ObjectIdentifier
FullFileName = aqFileSystem.IncludeTrailingBackSlash(Sys.OSInfo.TempDirectory) & FileName
Call SystemDialogFileSave(FullFileName)
SystemDialogFileSaveHandle = FullFileName
End Function
'-----------------------------------------------------------------------------