Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
13 years ago

window existence and button enabled / disabled

I am trying to increase the speed at which one of my scripts runs. I initiate an action in my application under test that is time consuming. The amount of time it takes to complete varies by machine and whatnot. I do not want to initiate a delay. I want to wait only as long as it takes to complete. I initate the time consuming action, which is an import. When the import is initiated, I see a window that says basically please wait. There is a button on the form which is disabled until the import is complete. When the import is complete, the button becomes enabled.



What I tried to do is



Do while true

    set frmImport = myProcess.WaitVBObject("configcrForm", 15000)   <--- this is the form that is displayed with the disabled button.

    set btnOK = frmConfirm.WaitVBObject("OKCommand", 2000)

    If btnOK.Enabled Then

        btnOK.Click 

        Exit Do

    Else

        Delay 2000

    End if

Loop





The form myProcess.WaitVBObject("configcrForm", 15000)   is never found. That line of script barfs. I find this weird since the code I am currently running:



  Delay 150000 ' have to wait for the import to process. This is time consuming.

 

  if myProcess.WaitVBObject("configcrForm", 5000).Exists Then

 

    set frmConfirm = Sys.Process("Instrument Manager").WaitVBObject("imconfigcrForm", 3000)

    set btnOK = frmConfirm.WaitVBObject("OKCommand", 2000)

    if Not btnOK.Enabled then   ' still importing wait another few seconds

      Delay 10000

    end if       

    btnOK.Click        

    

  end if



After the delay, the form is found just fine.



The funny thing is that when I initiate an import NOT from script, and try to examine that form in Test Complete's object browser, Test Complete does not respond until after the form's button is enabled. As if the system is spinning so hard, nothing can happen.





Any thoughts on how to accomplish this? What might be happening to test complete's understanding of this form?  Thanks




1 Reply



  • Do while true

        set frmImport = myProcess.WaitVBObject("configcrForm", 15000)  
    <--- this is the form that is displayed with the disabled button.

        set btnOK = frmConfirm.WaitVBObject("OKCommand", 2000)

        If btnOK.Enabled Then

            btnOK.Click 

            Exit Do

        Else

            Delay 2000

        End if

    Loop





    Is "myProcess" set to the appropriate process at that point in the script?  Whenever I have an issue finding something, I always double check to make sure everything in the chain was found.