how to create function library in OATS

Like Tweet Pin it Share Share Email

One of the basic advantage in Automation testing is the re usability of commonly performed actions or code snippets required as part of the Automation Framework.

Automation engineers have separate function libraries based on the purpose, for example: for automation testing of Oracle EBS applications, following is a non exhaustive list of function libraries:

  • For OAF Pages
  • For Oracle EBS Forms
  • For Reporting Purpose
  • For Log File
  • For Result File Generation
  • For Product Family wise ( i.e. common functions for Procurement Product Family, HRMS Product Family etc.. )
  • For dealing with Excel to handle test data.

Like any other test automation tools, even Oracle Functional Test of Oracle Application Testing Suite supports creation of function libraries through its Openscript IDE.

Lets see how we can create function library using Openscript

Steps to create function library:

  • Open openscript
  • Click New of File menu
  • Select any project type and click Next
  • Select the check box “Create script as function library

  • Create function library
  • Enter your desired function library name and click Next
  • Enter desired package name, it can be your organisation name or some package name like we create for any java application.
  • Enter your desired Class name, mostly same as your function library name.
    function library class name
  • Click finish.
  • Once the function library is created, end user can add the desired functions to be used in automation scripts.

Steps to use function library:

  • Create any new automation script
  • Go to Assets tab
  • Select  scripts node and click on Add
  •  assets tab for function library
  • Browse to the location where we have the function library created
  • Select the same and provide appropriate alias name ( this name would be used in the scripts to call the functions )
  • We are now ready to start using the functions in the function library.

Please feel free to ask any queries regarding this topic, I would be more than happy to help you out.

Comments (12)

  • what is the main purpose of using function libraries

    • Author

      Hi Satya Srinivas,

      Well the ultimate reason to have function library is re-usability, here below are some examples as why we need functions in a function library.

      1. Some times we need to have logic to address some looping logic, for example in Oracle Applications, whenever a concurrent request is submitted, we generally click on Refresh button to get the latest data of status of concurrent program. We can write this in the same test automation script, or it would be helpful to keep it out side of test automation script and make a function and keep it part of function library so that it can be reused in other scripts.
      2. Some times we might need a set of functions to deal with excel file or csv file or xml file or properties file, this is the case when we want to work with and would needed across different test automation scripts, so once the functions are written it could be re-used where ever required. WE might need to work with these files may be for test data iterations / excel verification etc..
      3. In some companies, they even come up with functions for each business function of the application under test, so that these can be reused to form different combinations of test scripts.

      similarly for different purposes, people want to have function libraries. Also the other advantage is once these functions are available these become central and so if any changes made to these functions they get reflected in all the scripts where these functions are used.

      If you are asking about what is difference between writing functions in a normal openscript and function library of openscript, they have brought this feature to have a user friendly calling mechanism. That was their sole purpose of introducing function library in openscript.

      Earlier to introduction of function library, if some had to call any function below would be the format to be used:
      But after introduction of function library the calling mechanism is as below, which is more user friendly.
      scritAliasName.functionName(“Param1Value”,”Param2Value”); and similar, just like how we call any methods in a class.

      Please do revert to me in case you have for any other purpose.

  • Hi,

    I have a question: How do you call a function from the function library (Assets) when the parameter is an array? Could you give me an example?


    • Author

      HI there,

      Sure I can give an example:
      Now if you want to have a function to sum up all numbers in a given array, first step would be to add a method which takes array of numbers as input and calculate the sum and print the same.

      	public void add(Integer[] nums)
      		int sum	=	0;
      		for(int i=0;i

      Assuming that this function library is already added to your script assets you can just call the function as below:
      Assuming the alias for the function library is test

      		Integer[] nums	=	{1,2,3,4};

      And now when you run you get an output as total value: 10 for the above input, you can make necessary changes accordingly.

      I have done this in OATS 12.5 version.

  • Hi! I would like to ask how we can prevent in adding the Function Libraries in the flow we have created from Oracle Flow Builder. Currently, for EVERY flow (script) we export from Flow Builder to OpenScript tool, we manually add the Function Libraries. If we have about 100 flows (scripts), then we wouldn’t want to manually add the Function Libraries to all 100 flows (scripts).

    Is there a way to do this one time big time?

    Thank you.

    • Author

      You can do this one time actually, what you have to do is, which ever scripts you are planning to execute, those need to be downloaded to the machine where you have planned to execute and should follow certain steps that is to create a repository and then add all the generic function libraries at that location. If this setup is done, you don’t need to add them every time you download the script from Oracle Flow Builder.

      Please do revert to me in case of any queries.

  • Hi
    I have just started learning OATS. I am good in Oracle EBS. Do you have any material that teaches me how to do testing in OATS?

  • Hi Srinivas,
    I am very much thankful to you for this blog. This has really helped me. Although i am facing and issue while automating an EBS form. In my scenario I need to open two different windows based EBS forms(one after another), so while recording actions objects are captured properly but while playback for form 1 it works fine but when open script opens form 2 it fails to identify objects. I am unable to figure out the main reason behind this.
    Error message: “Failure when running child script EBSCreateItem. Caused by: Send Playback Command Timeout! command:forms.formWindow(“//forms:window[(@name=’NAVIGATOR’)]”).activate(true), timeout: 10000″. As a workaround I am reopening the browser to open form 2 and perform action which works fine.

    Please provide your insights.
    Thanks and regards.

    • Author

      That is one of the best practices that many other companies follow too. so what you did is a good option to continue 🙂

  • Hi Srinivas,

    I have an issue while adding function library in the script. I created a function library named “UtilityScript” and adding as an asset to the parent script. But after adding, the import statements in the parent script started to show error.

    I was getting this error so many times. But the errors were disappearing when I restarted the openscript tool. Is this error related to workspace.

    The errors were in the line :
    import lib.*;
    @FunctionLibrary(“UtilityScript”) lib.est.UtilityScript utilityScript;

    I recreated the function library but still getting this error. could you please tell me what causing this error.

    Thank you ..

    • Author

      These are generally temporary issues, may be you need to close openscript and open it or restart machine then it might work properly.


Leave a Reply

Your email address will not be published. Required fields are marked *