How to call functions from another script

How to call functions from another script

I want to use the functions which used in other script in same suite.

Can anybody help me


  • EggplantMattEggplantMatt ForumAdmin admin
    This question was also submitted and answered via email. Including that answer here for completeness:

    There are several options syntactically for running a function or command located in a second script. I’ll assume the script is called X and the function is called A(); to call the function from script Y, you could do any of the following:
    put X.A(3,4)
    put X's A(3,4)
    put A of X with (3,4)
    put [X A:3,4]
    You can use whichever syntax is the easiest for you to remember or which feels the most natural to you. If you want to make a separate script for the function and the function is again called “A()” as above, then you would create a script called “A.script" and its contents could be like either of the below:
    function A var1, var2
    	return var1 plus var2
    end A
    or just
    params var1, var2
    return var1 plus var2
    You could then call the function by calling the script:
    put A(3,4)
  • Hi Matt,

    For calling the script from another suite I am using below command,

    I have a suite named as Test3.suite
    I am using another suite

    Run "C:\Automation\Test2.suite"

    But I want to use Function Download (var1,var2) from Login.script of Test2.suite

    How can I write the command for the above query ?
  • EggplantMattEggplantMatt ForumAdmin admin
    Sorry for the delay. Never saw this post until now.

    The best approach is to set Test2.suite as a Helper of Test3.suite. Then you can just call your function like this:
    put Login.Download("val1", "val2")
    Run "C:\Automation\Test2.suite"
    This code wouldn't do anything. You can't run a suite; you can only run scripts.
Sign In or Register to comment.