Forum Discussion

todd_james's avatar
todd_james
Contributor
12 years ago

User Forms, Distributed Testing and Test Run Scheduling

I have run into a problem with user forms and distributed testing that I am hoping someone might have a fresh idea for as everything I have tried has failed.

I have a project suite that I am running using a batch file (calls TestExecute to run a network suite on a remote host using the command line) and windows task scheduler. This project runs a distributed tested on a remote host on a set schedule.

Users can also run this project on a demand when required and I have created a user form that allows them to run the test suite against different environments. This part works okay but what I am struggling with is skipping prompting for user input if the test is running on a remote machine (ie via the distributed schedule test).

I have tried checking the NetworkSuite.State, job.state and task.State but these all still end up prompting the user for input when my batch job runs,

Any ideas on how I can only show the UserForm if a user kicks off the test and is running locally versus the batch job running the distributed test on a remote machine?

3 Replies

  • Moved the code to show the user form from the OnStartTest event handler to the first script run and it works okay.



    If the code is in the on start event, it runs the script both on the local machine and on the remote machine during the distributed test so the logic of checking for a NetworkSuite.State won't work.
  • Have you tried the Timers object to create a timeout if there is no interaction on your user form?



    http://support.smartbear.com/viewarticle/55006/



    Here is some code I had on that. It creates a userform with after setting useDefaultValues = true



    Then, all other interaction with the user form will set useDefaultValues = false.



    The timeOutForUserInteraction Sub will check if useDefaultValues is still true, and if so, assume it is an unattended run, hide the form and continue with the default values.






    Function Utils_BrowseFile_TimeoutForm(strDefaultFile, iTimeout)


      useDefaultValues = true


      pathFile = strDefaultFile


      


      Set form = UserForms.Utils_BrowseFileForm


      form.strFile.Text  = pathFile


      form.dlgBrowseFile.InitialDir = Project.Path + "Resources\"


      form.dlgBrowseFile.FileName = "" 


      form.ModalResult = mrNone


      


      isPathReady = false


      


      ' Adds a new object to the Timers collection


      Set Timer1 = Utils.Timers.Add(iTimeout, "Utils_BrowseFile.timeOutForUserInteraction", false)


      Timer1.Name = "BrowseFileTimer"


        form.Show


      Timer1.Enabled = true


      


      While Not isPathReady


        Sleep(1000)  


      Wend


      Timer1.Enabled = false


      Utils_BrowseFile_TimeoutForm = pathFile


    End Function 


     


    Sub Utils_BrowseFileForm_strFile_OnButtonClick(Sender)


      useDefaultValues = false 


      Set dialog = UserForms.Utils_BrowseFileForm.dlgBrowseFile


      dialog.InitialDir = Project.Path + "Resources\"


      dialog.FileName = "" 


      If dialog.Execute Then 


        Sender.Text = dialog.FileName


      End If 


    End Sub


     


    Sub Utils_BrowseFileForm_strFile_onUserInteraction(Sender)


      useDefaultValues = false 


    End Sub


     


    Sub timeOutForUserInteraction


      Log.Message ("timeOutForUserInteraction: " & useDefaultValues)


      Timer1.Enabled = false


      If useDefaultValues = true Then


        form.Hide


      End If


    End Sub


     


    Function Utils_BrowseFileForm_OnHide(Sender)


      If form.ModalResult = mrOk Then


        pathFile = form.strFile.Text 


      End If


      


      isPathReady = true


    End Function


     


    Sub Utils_BrowseFileForm_btnOK_OnClick(Sender)


      useDefaultValues = false


      form.ModalResult = mrOk


      form.Hide


    End Sub