Forum Discussion

mesg2anil's avatar
mesg2anil
Regular Contributor
13 years ago

Cannot obtain the window with the window class '#32770'...

Hi,



I'm calling function to validate a object which will popup a window if the value is inserted wrong. While validating the popup window I'm having trouble... below is the code




Function Validate_Month_Year



 


Set MainFrame = Sys.Process("iexplore", 2).Page("http://server/Default.asp").document.frames.Frame("mainFrame")


    MainFrame.document.all.Item("gvSalesBudgetForecast_ctl02_ddlYear").ClickItem("2011")


 


If NOT Sys.Process("iexplore", 2).Window("#32770", "Message from webpage", 1).Exists Then

 



 


Log.Message "Month and Year were within project estimated start date"


Else

 



 


Sys.Process("iexplore", 2).Window("#32770", "Message from webpage", 1).Window("Button", "OK", 1).Click


Log.Error "Month and Year are NOT within project estimated start date, different Mon / Year is selected"


End If

End Function



In the above function, if I insert wrong value, the popup is shown and the function correctly clicks on ok button on the popup, but the problem is if I insert the correct value, there will not be popup shown, so the script is trying to search the popup which is NOT there and erroring out as "Cannot obtain the window with the window class '#32770' window caption 'message from webpage' and index 1"



How to make this work? Please help!!



 

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Consider this.  If your Item does not exist, how can you call the "Exists" property of it?  While your logic is correct, you need to make a minor change.  Change your if statement to



    If NOT iexplore.document.all.WaitItem("Submit", 1000).Exists Then
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Jared,



    I'm with this below to check if the object is existing the I will return a message Fail, if the object is not existing i will return a message as Pass...




    sub add


    add

    Set iexplore = Sys.Process("iexplore", 2).Page("http://server/Default.asp").document.frames.Frame("mainFrame").document.frames.Frame("ContentFrame")


    If NOT iexplore.document.all.Item("Submit").Exists Then


    log.Message "Passed"


    Else


    log.Error "Failed"


    End If

    End sub



    It is working if the object is found, but if the object is not found it is erroring out as "Unable to find object Item("Submit")" How to resolve this issue? Please insist...!


  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Robert...



    Thank you very for the suggestion...! Its working fine now!

    Have a great day!!