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.

lambdatest

Comments (42)

  • 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
  • Hi Srinivas,

    Could you please help answering whichever is possible/all from these 4 questions related to OATS? :
    1.How is it possible to run OATS scripts in background so that browser sessions and the clicks(operations) within them can run in the background?

    2. Currently OATS only allows running of one script. This is because there is a single OATS agent per installation. Is there a way to run multiple OATS scripts at the same time from several source. (Several sources implies, running one test-case directly from OATS and other from command line for example).

    3. Currently OATS captures errors only by capturing screenshot, and provided OATS logs. But how to return the server logs that are captured at the time of the failure?

    4. If we need to run multiple test cases per day, is there a way to ensure that at least login page gets executed only once, such that remaining test cases can perform their action over the single existing browser login session. In other words can the common parts existing in the beginning be performed just once, such that the rest of the scripts piggy back on the initial step?

    Thanks and regards,
    Arun

    Reply
    • Author

      Hi Arun,

      Please find below my responses

      Response for Query 1:
      I dont think there is a straight forward option, well I would like to touch up on few things here

      1. Option 1: if you want to just test that the functionality is working without the UI, you could create a load script and stabilize it and run it as an end to end scenario.
      2. Option 2: When you use OTM( i.e. Oracle Test Manager ) the functional scripts run in an internal server, and user can chose either view the execution or not. So the script runs in background.

      Response for Query 2:
      Yes, the only option available is through command line, you can invoke execution for each script from command line and these can be triggered in parallel.

      Response for Query 3:
      Could you please let me know what do you mean by server logs? if you are referring to Application’s server logs, I don’t think there is single way to do it, it depends on which application you are working on, also for each application the server logs might be stored in different ways, we can only have a path displayed or download the files if we know the path where the server logs are recently generated. This is completely dependent on how the application was built and where exactly the server logs are generated.

      Response for Query 4:

      Yes this is quite doable, create all your child scripts in a way it always starts from navigation of ORACLE EBS Application’s navigation menu and ends with closing all pages and the web page comes back to the navigation menu. You can now call all these child scripts one after the other in a master script and before calling all these child scripts have another child script which logs in to Oracle EBS Application.
      But there are chances you might end up in troubles like, some times when the oracle ebs application’s web menu is expanded already, it might become quite challenging to navigate for a new path that is in the next child script, which other wise. This is how I would do as per the requirement stated.

      There might be more efficient ways too to solve these kind of requirements.

      I hope, I tried to give solutions for all of your queries.. please do revert to me in case of any queries.

      Thank You,
      Regards,
      Srinivas P.

      Reply
      • Hi Srinivas,

        Sorry about the delayed reply. Missed reading your response upto now. Thanks a lot for these replies. These are really useful. I am trying out a few of the suggestions you have given. Wil revert back once I try them out.

        Regards,
        Arun

        Reply
      • Hi Srinivas,
        I have a question regarding the following response of yours:
        ============
        Response for Query 2:
        Yes, the only option available is through command line, you can invoke execution for each script from command line and these can be triggered in parallel.
        =====================

        From the OATS user guid i found the parameter “-web.launch_new_browser” which is said to be set to ‘true’ by default. However when I open two ‘cmd’ instances on my windows box, and execute two jwg trhough command line (using Firefox browser) I get an error saying there is an existing browser session and must be closed. I tried repeating the same for IE, but there though it launches the two browser sessions, I am not quite sure if the web.launch_new_browser is actually getting used. I ask this because when i actually explicitly set “-web.launch_new_browser true|false” to false, even then IE was launching two browser sessions. So wanted to confrim if i am attempting the parallel browser launch the right way or if i am missing something. Becaue ideally irrespective of the browser, we should be seeing a clear behavior of browser session getting launched (or not getting launched depending on the parameter) , and this is something I don’t see happening.

        Thanks again for all the help.

        Regards,
        Arun

        Reply
        • Hi Srinivas, Just realized that web.launch_new_browser is not designed to address the issue of parallel browser executions of test cases. I therefore would like to ask an open ended question about what exact command option will help for the purpose of launching multiple OATS Scripts in parallel (in different browser sessions).

          Thanks,
          Arun

          Reply
          • Author

            Thank you Arun for reaching out to us.

            Well that happens only with Command Line option of triggering a script, you can get introduced to basics of command line execution.

            Please do revert to us in case of any queries.

            Thank You,
            Regards,
            Srinivas P.

  • Hello I have started to work with openscript a few months ago and I am getting an error trying to click on a choicebox button, the error says object not found but if I try to read the title content for example, it can be found with no problems.. this element does not have any other property or at least the recording tool only shows forms.choicebox to find it and it is the only element of it´s kind in the screen.. I don´t know where else to look for this could you give me some clues on this? thanks!

    Reply
    • Author

      Could you please try to spy the object and get the properties and property values for the checkbox? also could you please share the error details here?
      Some times you will get more properties when you a object test from the tool. So from there you can get additional properties to add to xpath, i hope it might help you in that regards.

      Reply
  • Hi,
    OATS playback executes each line in the script one by one and we can see yellow highlighter while playing each line.

    I am working on lengthy script, if there are try catch statements in the script, while OATS playback the yellow highlighter stops at try statement and shows Running instead of executing every line in the script which is the default playback option.

    Is there any reason why the playback is not happening every line if we use loops like try catch or if statements

    Reply
  • OATS OpenScript version (Openscript v13.2.0.1 build 173) default playback executes each line in the script one by one and we can see yellow highlighter while playing each line.

    I am working on lengthy script, if there are if statments, try catch statements in the script, while OATS playback the yellow highlighter stops at if or try statement and shows Running instead of executing every line in the if or try statement script.

    Is there any reason why the playback is not happening every line if we use try catch or if statements. Screenshot attached.

    Playback stops at first statement if or try loop and says Running as shown in the screenshot.

    Reply
  • Hi Srinivas,

    I am new to OATS(OFT and OLT).
    Need your help in resolving one issue.
    While playback of OFT and OLT script for one of our modules,i am facing the following error:
    “Finding Assets and Loading the script bundles”.I am not able to understand why i am getting this error.
    For same application(for which OFT script is created),i created simple login logout,that is working fine.

    Please guide

    Regards
    Amrita

    Reply
    • Author

      Hi Amrita,

      Thank you for reaching out to us, It might be good, if we can get on to some discussion here to understand more details.
      1. Are you trying to use OFT scripts in OLT? / Are you saying you have scripts separately for OFT and OLT and when running them you are getting error?
      2. You also mentioned that for same application , for which OFT script is created for login and logout it is working fine.

      kind of confusing 🙂

      is it possible to either share the script code or let me know the structure and assets being used for which scripts etc.., also see if you can get on to an email(testingtools.co@gmail.com) or whatsapp(9885809854) conversation.

      I would try my best to help you out.

      Reply
  • Hi,
    If we have multiple child scripts configured will they be executed in parallel when the master script is run? Or would it be sequential? And does Openscript support multi-threading?
    I’m looking for optimization options to decrease the total run time of the suite, and hence would like to check if there’s anyway parallel runs can be set for the flows through different child scripts.

    Thanks,

    Reply
    • Author

      Hi Meenakshi,

      Thank you for reaching out to us, there is no straight forward feature given by OATS to run scripts in parallel from the same master script.
      But still we can achieve this using command line execution of scripts, you can open 2 or multiple command prompts and trigger execution of different scripts in parallel.

      Hope this helps, you can reach to me for any further queries.

      Thank you,
      Regards,
      Srinivas P.

      Reply
  • vey nice post.
    Can you please post a single oats script with most of the best practices included in it – which can be used as a reference for beginners?

    you may take any generic website…

    Reply
    • Author

      Hi Rauf,

      Thank you for reaching out to us its a very good idea, it might take some time to build something like that share it over here.. hope it happens soon.

      Reply
      • Hi Srinivas,

        Your replies are really informative.

        I am very much new to Open Script tool. I have a requirement where after generating sale order number, i have to perform Confirm shipment for the same sales order. How to store newly generated sales order number in a variable and at which point. Also, how to use the newly generated sales order number for confirm shipment.

        It will be really great if you can share the code if you have implemented it earlier.

        Reply
        • Author

          Well it goes this way:

          • First get the sales order number from the form and save it in a variable.
          • Use it where ever you want to.

          When you have a single script where you book Sales Order and also use it in another place

          //Step 1:retrieve and store value in a variable from a text field
          String ordNum = forms.textField("[Name Attribute of SO Field]").getText();
          //Step 2: 
          forms.textField("[Name attribute of the field which you want to use later]").setText(ordNum);
          

          When you are working with multiple scripts

          //Step1: Capture value in script 1
          String ordNum = forms.textField("[Name Attribute of SO Field]").getText();
          getVariables().set("SO_NUMBER",ordNum);
          //Step2: Use captured value in another script
          String ordNum = getVariables().get("SO_NUMBER",ordNum).toString();
          forms.textField("[Name attribute of the field which you want to use later]").setText(ordNum);
          

          Hope this is helpful, in case you need anymore help you could reach out to us.

          Reply

Leave a Reply

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