Forum Discussion

amruthraj's avatar
amruthraj
New Contributor
8 years ago
Solved

How to Skip a Line in Test Complete during Execution

is this possible to create a function which takes a string input , if string matches then skip the execution to next line.  

 

ex:-

sub Login(userName, password)

Aliases.browser.AdminSignIn.Username.SetText  IsSkipped(useName)

Aliases.browser.AdminSignIn.Password.SetText  password

End Sub

 

here isSkipped() is a function which takes string as input and If String is ''skip'' then execution will be skipped to next line, without setting the value to user name field

  • You are using now,

     

    Aliases.browser.AdminSignIn.Username.SetText  IsSkipped(useName)

    Aliases.browser.AdminSignIn.Password.SetText  password

     

    Instead of this, I would say for entering the field you can create a common function as below.

     

    Function EnterTextBox(ObjectTextBox,ValueToEnter,fridenlyName)
    
    If ObjectTextBox.Exists Then
     
     If ValueToEnter <> "Skip" Then 
       ObjectTextBox.SetText(ValueToEnter)
     Else
       Log.Message(fridenlyName & "textbox skipped")
     End If
    Else
    
     Log.Error(fridenlyName & "Object does't exists")
    
    End If

     

    To implement above just call like below,

    EnterTextBox(Aliases.browser.AdminSignIn.Username,"<valuetoenter>","User Name")

3 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    If I correctly understood you, better to do it within the login function.

     

    Pseudo code:

    function login(user_name, password):
      
      if user_name:
        Aliases.Username.SetText(user_name)
        Aliases.Password.SetText(password)
    
      else:
        Aliases.Password.SetText(password)
    • amruthraj's avatar
      amruthraj
      New Contributor

       

      in our project we have some test where we skip the some of field values, so what i need is  while setting the value , i will call the function , which takes string input, if the given input is "skip", then it should skip the execution to next line ,else it should enter the value to field.

      so i can call the same function before setting any values and pass the parameter  value as "skip" if i wanted to skip that field. 

       

      currently we are using VB Script for scripting

      • shankar_r's avatar
        shankar_r
        Community Hero

        You are using now,

         

        Aliases.browser.AdminSignIn.Username.SetText  IsSkipped(useName)

        Aliases.browser.AdminSignIn.Password.SetText  password

         

        Instead of this, I would say for entering the field you can create a common function as below.

         

        Function EnterTextBox(ObjectTextBox,ValueToEnter,fridenlyName)
        
        If ObjectTextBox.Exists Then
         
         If ValueToEnter <> "Skip" Then 
           ObjectTextBox.SetText(ValueToEnter)
         Else
           Log.Message(fridenlyName & "textbox skipped")
         End If
        Else
        
         Log.Error(fridenlyName & "Object does't exists")
        
        End If

         

        To implement above just call like below,

        EnterTextBox(Aliases.browser.AdminSignIn.Username,"<valuetoenter>","User Name")