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
- 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.
- 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
- 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.
what is the main purpose of using function libraries
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:
getScript(“scriptAliasName”).callFunction(“functionName”,”Param1Value”,”Param2Value”);
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?
Thanks
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.
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.
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 Ron,
As of now you can refer to @ OATS functional testing tutorial Index , keep watching I will be adding more and more tutorial articles.
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.
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 ..
These are generally temporary issues, may be you need to close openscript and open it or restart machine then it might work properly.