Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
9 years ago
Solved

How to call a script?

I have copied the example from help to send the testlog via email as described here:

 

Now, when I want to call this code from a Keyword Driven test, by using the function "Run Script", I get the following error message: "There is no appropriate test to choose".

 

 

  • Found out I needed to use:

     

    Sub [name] ()

     

    End Sub

     

    Thanks chik!! :)

     

5 Replies

    • mgroen2's avatar
      mgroen2
      Super Contributor

      Marsha_R 

      here is the example script:

       

      --------------

      If SendMail("m.groen@BLABLA.COM", "smtp-mail.outlook.com", "testrunner", "testrunner_dp@BLABLA.COM", "Notification", "Hello Clare, Your application is nice.", "C:/a/File1.txt") Then
      Log.Message "Mail was sent"
      Else
      Log.Warning "Mail was not sent"
      End If

       

      --------------

       

      I have copied the script from an example in the Help file. I have saved this script as "Unit1".

      After that created an Keyword test, I want to call this test in this keyword test but I get the error "No appropriate test to choose from".

       

      • mgroen2's avatar
        mgroen2
        Super Contributor

        Found out I needed to use:

         

        Sub [name] ()

         

        End Sub

         

        Thanks chik!! :)

         

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    Make sure the script is located in the same project as your keyword test.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Mathijs,

     

    Make sure the script code is inside a procedure/function. For example:

    // JScript
    function Test() {
    // Code goes here
    }