HomeOATS

24 Best practices for OATS – OFT/Openscript

Like Tweet Pin it Share Share Email

In this article you will know some of the test automation best practices we recommend for Oracle Functional Testing of Oracle Application Testing Suite (a.k.a OATS).

Best practices for test automation with OATS are typically identified from the test engineer’s experiences and challenges. In a real time scenarios,for example: situations where multiple teams work on similar kind of test automation tasks, team(s) might want to know the guidelines or methodologies in peer teams, as they might have observed following which have helped them attain better results and success rate.

Please find below:

Best practices for test automation in Oracle functional testing of Oracle Application Testing Suite.

Covering in the areas of :

  • Script Naming
  • Assets
  • Scripting / Stabilization
  • Script Execution
  • Script Settings

Script Naming related best practices

S.No Best Practice Purpose
1 Script name should contain only alpha numeric characters without any special characters except “_”

Script_Naming

To avoid unexpected errors by Openscript with special characters in a script name.
2 Make sure the script name is short, meaningful an less than 60 characters in total Sometimes, Openscript might through errors to execute scripts for which the length of script name is more than 60

Assets related best practices

S.No Best Practice Purpose
3 Try to avoid calling multi level child scripts.

Avoid_Multi_Level_Childscript_Calling_Not_Suggested

Avoid_Multi_Level_Childscript_Calling_Suggested

Might cause some instability issues when dealing with databanks and for multiple iterations
4 Any re-usable assets attached, most likely have them relative to repository unless they are present inside a script folder Helps for easy script movements from one location to another without export and import processes.
5 Try not to use java classes for re-usable methods or libraries as much as possible, unless for special cases.  This might need little technically skilled people and also some times Openscript might throw Object cannot be resolved error.

Scripting related best practices

S.No Best Practice Purpose
6 Avoid index attributes to identify objects for web applications for all UI components except for document and form.

In case you are recording the scripts, try to make these index attribute removal for desired UI components in object identification for Recording > Web Functional

Regular way:
web.window(“/web:window[@index=’0′ or @title=’Google’]”).waitForPage(null);

Better way:
web.window( “/web:window[@title=’Google’]”).waitForPage(null);

Most of the times the scripts will fail if index attribute is present the list of attributes used to identify an UI component in XPath
7 Change all waitForPage(null) statements to waitForPage(200,true) in case you are stabilizing a recorded script.

Here 200 is an example, you can have a global variable in case you want to use across different scripts and be maintained from single place.

Or if you are writing scripts without recording, please make sure you use waitForPage with 2 parameters and 2nd parameter value to be true.

Regular Way:
web.window( “/web:window[@title=’Google’]”).waitForPage(null);
Better Way:
web.window( “/web:window[@title=’Google’]”).waitForPage(200,true);
Or
// PAGEWAIT is a global variable where it is maintained at master script level to control from one place
web.window( “/web:window[@title=’Google’]”).waitForPage(PAGEWAIT,true);

 Openscript scripts might fail in the places where the page is already loaded faster than the execution speed of script, in these cases OATS may not understand if page is already loaded and expects for the page to load, this will generally cause scripts to fail.

The moment we give true as second parameter, the script will not wait if already the page is loaded

8 Instead of having think statements in the script, always better to have a waitFor(time) on the target object which are going to perform operation in the next step. This will reduce the chances of failure of script for different conditions of Application under test, in the sense time taking to load the page or objects refresh in page.

This is also important for the places where AJAX requests are also there.

9 Any objects or elements if the attributes used for identifying them are not unique / not constant, then it is better to identify those objects based on some label or prompt present near by to it.

i.e. dynamically get an objects based on any label associated to that specific object by using methods like

getElementsByTag, parent, etc..

Brings more stability in the script as the objects are identified based on the associated labels, especially for the cases where the attribute values to identify an object are changing frequently and not unique.
10 Use custom verification points than the checkpoints that can be auto inserted using Openscript IDE Most of the tool based checkpoints are static and may not work for dynamic content like table data verification. that is data present in a web table.
11 In case you are using scripting based test automation frameworks, it is suggested to have shared Object Libraries instead of XPaths being made as part of scripting it self. If object attributes are part of scripting it self, it might increase the over head of maintenance, if there will be in any changes in objects / unique attribute to identify an object.
12 Try avoiding multi level nested looping conditions in the scripts. It will take more time to identify if the issue for failure of execution is due to a script issue or a functional issue.
13 Try creating the scripts simpler and not have too much generalisation to satisfy different scenarios in one test script. This will create challenges at the time of debugging the scripts or to make any maintenance in the scripts.
14 Modularize your scripts to have better re usability Increases speed of script development as time passes on.
15 Try to develop individual scripts which may not run more than 30 mins, avoid as much as possible in having lengthy execution time based scripts.  With shorter execution time period scripts, the stability of the scripts is higher.
16 Any values captured from Application under test, try to save those values to physical location(i.e. files) and also print to log or result file to have them for reference.

 

Generally when scripts fail in between and you want to continue execution of remaining part, we can assign these values and run the remaining part of the script, which otherwise we might lose the data that got captured in the script execution for resuming the scripts which have stopped abruptly for unknown reasons or some issues.
17  Write appropriate info statements at different parts of the script to make them visible properly in the final result file.  Helpful while debugging the scripts.
18  Go through your entire application and identify what are the attributes generally used to identify an object uniquely and come up with the list of attributes for each object in the application and circulate to the entire team working on this, so that every would be in sync to use the same. Brings a standard approach for building a better scripts.
19 The cases where we have web tables in the application under test and if we have to perform operation(s) on an object based on values present in other columns, it is better to dynamically find the row in which the values are matching for the respective search columns and then dynamically get the target object from the target column for the same row and perform the desired operation. Data in web tables are generally dynamic and the order of showing the data in web table will always change based on other transactions in the application under test, by writing logic like with this kind of approach can bring stability in the script.
20  Regularize the attributes in the XPath, which will help to identify the object uniquely without fail.

for example: a web page / window object is identified with a title and the value for this title attribute is “Order Creation 1235”, and this is the only attribute which can help to identify this window object.

So the script might file fail the next time we execute with the same attribute value, but instead if we regularize saying “Order Creation*” then the same script can run without fail multiple number of times.

Brings better stability in the script for multiple runs.

Execution related best practices

S.No Best Practice Purpose
21 Have a shared location, where you can store execution results for each cycle w.r.t each test script which were executed during the cycle.

These result folders would be present in each script / Master script. Generally found in this location

Master Script > Results > SessionXYZ

Here session XYZ  is something we need to figure out and keep them

Results_Location

As a general practice people might delete the results post executions once they feel everything is fine, but by doing this we can have a reference any time to go back and check on need basis.
22 Have a practice where a script would be stabilized by one person and have another person in the team to run the same script for 3 times, out of which it has to pass at least for 2 times. You can get better confidence on the script that every thing is working fine, which is also called as dry runs.

Settings related best practices

S.No Best Practice Purpose
23 Based on the need if you want to have multiple child scripts to run irrespective of whether the execution of previous child script fails or passes, we need to have this setting saying continue executing the child script in the Openscript Settings.

Continue Execution

Helps to continue to run scripts in unattended mode,there by can run scripts at the night times and can check the status of all scripts in the next day morning start doing the failure Analysis.
24 Enable the setting in Openscript to take screenshot on any script failure.

CaptureScreen_On_Failure

This will help speeding up the Execution failure analysis, especially when having the nightly / unattended script executions.

In case of any queries, kindly reach to us through comments and we would be more than happy to help you.

Comments (22)

  • Hi Srinivas,

    Very nice place to LookUp page for people who really want to get on to this tool…
    I really felt the below one will also be a best practice..

    Setting of Record Webfunction or ADF Function>Object Identification for people who are using OL.This will be very handy if we import XML with proper naming convention and formating..

    This will be very useful for project involving a OL…Where the objects can be added with proper naming convention.

    Reply
    • Author

      I am glad that you liked it Sukhinder, and thank you for sharing your experience about the settings when people using Object Library.

      Reply
  • Hi Sriniva,

    Really its Good Article, really its make more information about Assets , its help in Really Time environment , thank you for the post. please continue with new Topics ,Appreciate for you work

    Regards
    Manoj Kumar

    Reply
    • Author

      Hi Manoj,

      I am glad that the blog articles are interesting for you and adding value, and I will surely continue to add more topics, please do let me know if you have any topics, I shall try my best to cover them over.

      Thanks,
      Srinivas P

      Reply
  • Hi Srinivas,

    This is really a good information. In our company we recently started working on Open script automation tool. We got couple challenges on the installation side. Now we are fine with the installation. But we have couple of issues on the recording and playback the results. I would like to check with you off line if can give your mail ID or phone.

    Regards
    Srinivas G

    Reply
    • Author

      I am glad that you found my blog on Oracle Application Testing suite which covers a good amount of articles around various tools 🙂

      And Sure Srinivasa Rao, I would be more than happy to help you out, as long as I can

      You would receive a mail in short time, we can continue from there.

      Thanks,

      Reply
  • Good points with detailed explanation for each.

    Reply
    • Author

      Thank you so much Namrata, I am glad you liked, these are some of the important ones which I thought are useful, please feel free to add your points too in the comments so that I can pull them up in to the actual post 🙂

      Reply
  • I am trying to Run ADF application through master driver (which is an script and calling the child script) and it fails with the error message :
    Adf page cannot sync with server within 90 second(s) openscript error.

    Can any one help with this issue .

    Thanks in advance .

    Regards,
    Chetan

    Reply
  • Author

    Hi Chetan,

    Thank you for reaching out to us on Oracle ADF based application automation using Oracle Application Testing Suite. Before going deeper, want to know information like
    1. Which version of OATS is being used along with the browser and versions?
    2. Did you select ADF plugin for the script?
    3. Has the settings been enabled in the background for the ADF application, for it to be identified with ADF project type, while creating the script?
    4. Is that the only error you see? Can you post the full error from console over here?
    5. What is the timeout that is selected for Playback on ADF in the script preferences window? Did you try increasing and checking the same?

    Reply
  • Hi Srinivas,

    I have a query related to child scripts concept.
    As per my knowledge, we need to associate required child scripts manually in the assets section when we design the master script.
    But is there any way to associate the child scripts during runtime?

    Thanks,
    Aisha

    Reply
    • Author

      Hi Aisha,

      Thank you for reaching out to us on Oracle Application Testing Suite as how to dynamically associate child scripts, ideally there is no direct way available, instead you could do couple of things.

      1. There is an API in OATS to call scripts in RunTime, which eliminates the step of dynamically associating at run time.
      API: runScript(“reponame”,”path to script from repo”,number of iterations);

      2. There is a command line utility called “osclti” which has an option called “UpdateAsset” you open a command prompt window and then change directory to c:\OracleATS\openScript and give commands like osclti -help , you would get 3 options, out of which one is related to assets , you need to follow those options and you would be able to associate assets from command prompt and then later execute the scripts.

      you could explore above options, till I come up with a detailed article for the same, but may I know why do you want to do this dynamic association? it would be great learning for readers to understand in which scenarios we might want to perform the activities which you were referring to.

      please do revert to me in case any further queries.

      Thanks
      Srinivas P.

      Reply
  • Hi ,
    I have scenario like
    Create Sales Order
    Release applied holds on the sales order
    Release sales order
    do a shipping transaction of the sales order
    Run Auto Invoice for the same sales order
    Check if the Invoice is generated of that sales order.

    Shall we create single scenario for all the test case
    or we should have individual test cases and club them into one parent script.

    Parent script will call all the individual scripts.
    In case of individual test cases, how do we passed generated sales order number to subsequents scripts. ?

    Reply
    • Author

      Hi Pradeep,

      Thank you so much for reaching out to us.

      This completely depends on the project scope and amount of automation involved in the project. As long as some of the functionalities which can be reused across different flows, it is always better to split them in to parts and re use them. Saying this, it is good to have re usability, but we should be very careful about the amount of changes you need to keep doing in the re usable test cases. I have seen many organisations fall in to a trap by modifying the re usable test case in order to achieve higher re usability across different flows, but they end up wasting time during script executions, especially when a script fails. They have to spend more time in debugging where exactly it failed.

      Instead derive at a limit of re usability with less number of modifications anticipated.

      The time when you have re usable tests, there is a possibility to capture Sales order in one script and can be passed on to further scripts in many ways, few of the cases are as below
      1. Capture the values in Global Variables of OATS , so that the values remain across different child scripts when called from a parent script.
      2. Capture the values in to persistent files like properties files / xml files / excel / other options which ever is your wish and in the next steps, you could retrieve values from the respective files.
      3. Capture the values in to any Databases, so that in the next steps values can be retrieved from database and be used it in further steps.
      There might be many other ways too.. its all about your flexibility in coding etc..

      hope this has given you the details asked for, please do revert to us in case of any further queries.

      Thanks,
      Srinivas P.

      Reply
  • Hi Srinivas,

    Thank you for this article!
    I wanted to learn more on the web element locators in OATS? Can we locate elements by id, name, link text like in Selenium or only xpath? Can we build our own xpath locator by inspecting the elements and use them in the scripts?
    Can we automate Angular JS single page applications using OATS? This page is compatible only on chrome, so am not sure if we can use OATS for this?

    Regards
    Amrita

    Reply
  • Hi Srinivas,

    Can we capture a dynamically generated number ( Requisition ID), store it in a variable and use it in other scripts? Could you please refer the steps to perform this?

    Thanks,
    Harjyot

    Reply
    • Author

      Yes HarJyot,

      It is very well possible and is very simple too.Just follow below steps til I come up with a detailed post on the same.

      Step 1:
      Capture Value from say a text field
      String reqID = web(“[xpath]”).document(“[xpath]”).textField(“[xpath]”).getAttribute(“value”).toString();

      Step 2:

      Store the capture value in to a global variable which is understandable by OATS
      getVariables().set(“reqID”,reqID); // you can give any name

      Step 3:
      You can now use them in any script, i.e. the assumption is you are triggering multiple child scripts from a master driver script, and you have done above 2 steps may be in any of the 1 or 2 child scripts , so now you can use the stored value in any number of scripts after 2nd child script and also from the place in 1st or 2nd child script where the value is set in to global variable / scope.

      Now you can use the following statement to get the value stored in the global variable as below:
      String requisitionID = getVariables().get(“reqID”).toString();
      //reqID should be exactly same with case, otherwise you will get an error saying variable not found.

      Hope this helps, please do revert to us in case of any queries.

      Reply
  • Thank you so much. This is really helpful. I am still struggling to capture value from a html table. Can you please provide more examples on capturing variables using xpath?

    Reply
    • Author

      Hi Harjyot,

      Thank you for reaching out to us and glad that it is helpful to you, request to kindly share some scenario with some publicly accessible website(can be the application you work as well), so that we can give some live example.

      Reply
  • Could you please navigate to http://demoqa.com/registration/

    I want to read the value of the label- “First Name” and its value in the textbox

    Reply
    • Author

      Are you saying you want to capture 2 things, one is the value of the label “First Name”, second is the value present in the text field which is present beside the label?

      Reply

Leave a Reply

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