This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Where we can write UserDefined ( ApplicationFlow Based logic) Functions in Silk4Test Open Agent, How to call that defined function ? Any Example ?

Where we can write UserDefined ( ApplicationFlow Based logic) Functions in Silk4Test Open Agent, How to call that defined function ? Any Example ? 

4test.txt is used to define function to get help related to function right . then where we can develop the userdefined function

  • Suggested Answer

    0  

    Hi  

    These functions/methods/constants should be created in your own Include file (*.inc) and you should never modify any of the Include files shipped with Silk Test.

    1. In Silk Test Classic, select "File > New".
    2. Select "4Test include" as the file type.
    3. A new file will be created in which you add your functions/constants/variables/methods/winclasses etc.
    4. For example:
      [-] Login_To_WebApplication(String sUsername, String sPassword)
      	[ ] WebBrowser.SetActive()
      	[ ] WebBrowser.BrowserWindow.UsernameFld.SetText(sUsername)
      	[ ] WebBrowser.BrowserWindow.PasswordFld.SetText(sPassword)
      	[ ] WebBrowser.BrowserWindow.LoginBtn.Click()
      
    5. Save the file and add it to your project.
    6. To make the functions/constants/variables/etc available to a script you can either:
      1. Add the file to Runtime Options Use Files field.
      2. Add a "use" statement to beginning of the scripts/includes files that need access to the functions/constants/variables/etc. For example:
        [ ] use "AppFunctions.inc"
        

    The function(s) can be invoked from a testcase as follows:

    [ ] use "AppFunctions.inc"
    [ ] 
    [-] testcase demo()
    	[ ] Login_To_WebApplication("my_username", "my_password")
    

    I hope that helps.

    Regards
    Robert

  • 0

    Thank You Robert, Will try to implement the same.

  • 0 in reply to 

    Hi Robert,

    I have successfully implemented user defined functions and its working too.

    But 1. im facing an issue after using []use "xyz.inc" also (with out providing file path in Options-Runtime-Usefiles) getting error like Variables not declared . do we need to provide complete Path of the Inc(Objects and Properties(obj repository)) file ?

    2. for every function calling its invoking the Application

    any suggestions/solutions ?

  • 0   in reply to 

    Hi

    If you are receiving a compilation error such as "is not defined", it means that there is file in your framework that has not referenced the include file where the functions/variables/constants/etc are defined. If you double click the compilation error it should take you to the problematic file and you can add the required "use" statement.

    With regards to providing the complete path, if the include file is in the same directory as the file(s) that need to reference it, you can simply just specify the filename. If the files are stored in different directories a relative path or the full path can be specified. For example:

    • Relative path: use "..\IncludeFiles\AppFunctions.inc"
    • Full path: use "C:\Projects\WebProject\IncludeFiles\AppFunctions.inc"

    regards
    Robert