Forum Discussion

Pokis's avatar
Pokis
New Contributor
9 years ago

cant click open/save in IE, zero-sized window error

Hello,

What I am trying to accomplish is test file download  via IE (windows server r2 2008). I get a download promt at my IE, and I can accomplish clicking open or save for the first time. However when I try to download file again (let's say first time I tried open, second time I'm trying save) I get an error of "There was an attempt to perform an action on a zero-sized window". 
Tried focusing on the promt window, doesn't help.
debugged, the size is not zero (even highlights it on the browser properly),
tried refreshing mapping info, no luck
The prompt is rendered nicely.

Mapping is all fine.

Was thinking that new promt is created, but old one is directed, but I think info shows otherwise as I can focus, see it and debugging show's that windows info.

 

What am I missing?

Edit: If i try recorder, i get same aliases for both prompt windows, however launching script it works only for the first time and refresh mapping does not help.
Edit2: Only temporary solution I got so far is restarting IE every time i want to do another move with the files, that helps, but need to patch it up and do it properly still.

 error1.JPG

3 Replies

  • jb's avatar
    jb
    New Contributor

    You can try using the FindChild method (with array as parameters for search criteria). I guess you will see by using object browser that old "popup" is still here but 0 sized.

    You can also use FindAllChildren to check if Width or Height are > 0

    Mapping can cause this kind of issue from my own experience

    • brijmitchell's avatar
      brijmitchell
      Contributor

      I had this same issue when upgrading out tests to run in IE11, first of all i needed to map the objects, as they were new objects but for the engine to recognize them i needed to change my project configuration.

       

      I found that adding the following to the accepted windows allowed me to map the save and open buttons

       

       

      Click Tools and select "Current Project Properties"

       

      Add "Internet Explorer_Server" and "DirectUIHWND"

       

      Please see Screenshot

       

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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
    '-----------------------------------------------------------------------------