Forum Discussion

kandy1984's avatar
kandy1984
Contributor
9 years ago

Testing Modal Windows

Hi,

 

I am trying to perform some actions on a modal form (click on Cancel button) which opens when i clicked on the green '+' button. I have read about it in http://support.smartbear.com/viewarticle/72921/ . In this topic, it has asked me to use Runner.CallObjectMethodAsync(w, "MyShowModalDialog", "Param1", "Param2") method. But i do not know what is MyShowModalDialog and where i can get it from. Can someone tell me where i can see this name of the form which is modal?

 

Thank you.

 

Sudha

  • kandy1984's avatar
    kandy1984
    9 years ago

    Hi Tanya,

    Thanks for replying. We have figured out how it works now. i have asked my developer to have the button click in a function and i have used the function in the code. This worked perfectly.

     

    Thank you.

     

    Sudha

  • Hi,

     

    I have understand that the "MyShowModalDialog" event is where the click event is started. I am currently using the 'Object Spy' to go over the button to see its Properties, Fields and Methods. Where exactly can this be found in TC or do i have to ask my programmer  on the name used in vb.net?

     

     

    Thanks for helping.

     

    Sudha

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Hi Kandy1984,

       

      Let me quote the topic you’ve found:

      In the code snippet below, the tested application’s name is MyTestApplication. This application has a form named Form1. The form class contains the MyShowModalDialog method that displays a modal window. This method uses two string parameters and returns an integer value as a result.

       

      From my understanding, you can get the information you need from your developers.

      • kandy1984's avatar
        kandy1984
        Contributor

        Hi Tanya,

         

        Thanks for helping me. Yes i have asked my developer the equivilent for MyShowModalDialog which is btnAddWellType_Click. However, the code was not able to open the modal form "frmWellTypeEdit" which should appear after the button is clicked to open the modal form. Is there any other specific method that needs for the code to work?

         

         

         

        Sub Test()
        ' Obtains the desired object
        Set p = Sys.Process("PFU-3")
        Set w = p.WinFormsObject("frmWellEdit")


        ' Calls the method that displays a modal window
        Set ResObject = Runner.CallObjectMethodAsync(w, "btnAddWellType_Click")



        Set w = p.WinFormsObject("frmWellTypeEdit")
        If w.Exists then
        w.WinFormsObject("btnCancel").ClickButton ' Close
        End If

         

        ' Waits for method completion
        ResObject.WaitForCompletion 2000

        ' Processes the result
        If ResObject.ReturnValue = 1 Then
        Log.Message "Success"
        Else
        Log.Message "Failure"
        End If
        End Sub

         

         

        Thanks for helping once again.