Forum Discussion

shankar_r's avatar
shankar_r
Community Hero
8 years ago

Script Extension for Data driven framework!

Hi All,

 

I have prepared a Script Extension for Automation framework (DataDrivenFramework) I guess today is the right to day to present this here.

This Script extension controls the execution and generates the Awesome HTML report. And simple to implement.

 

To implement this, you need setup below things. I have attached sample project for this.

 

  1. Download DataDrivenFramework.tcx file from attachments
  2. Follow the instructions in the link to install the Script extension https://support.smartbear.com/testcomplete/docs/working-with/extending/script/installing-and-uninstalling.html
  3. Create a function in anywhere in your project and do as below
    	VB:
    	
    	Function InitExecution
    	     'This is to initiate the execution
    		adFramework.startExecution()
    	End Function
    
    	JavaScript/JScript:
    	
    	Function InitExecution
    	     'This is to initiate the execution
    		adFramework.startExecution()
    	End Function
  4. Usually in TC you will Log.Checkpoit or Log.Error functions in-order to make reports but here instead of that use below functions to do the same. It will create TC logs as well as HTML reports.
          //For adding a passed step
          adFramework.CreateTestStep(1,"Expected result","Actual result","Testdata used");
    
          //For adding failed step[by default you will see the screenshot in the HTML report]
          adFramework.CreateTestStep(0,"Expected result","Actual result","Testdata used");
    
          //For adding warning step
          adFramework.CreateTestStep(2,"Expected result","Actual result","Testdata used");
    
          //For adding warning step with screenshot
          adFramework.CreateTestStep(2,"Expected result","Actual result","Testdata used",true);
    
          //For adding done step [like clicking buttons, and some information messages]
          adFramework.CreateTestStep(3,"Expected result","Actual result","Testdata used");
    
          //For adding a Title
          adFramework.CreateTestStep("","Title","","",false,true);
  5. In your scripts you need to get the from the Excel for each test case for that you can use below functions
    //To get the test data from the excel sheet
    adFramework.GetTestData("ColumnName");
    
    //To get the environment from environment sheet
    adFramework.GetEnvironmentData("ColumnName");

 

That's it you got your Data-driven framework. Happy automating!

Feel free ask your clarifications on this!

 

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Great one! Thanks for sharing the extension with us, Shankar.

     

    I'll let our Support Team know so that they could suggest it to our customers as well :)

     

     

    • shankar_r's avatar
      shankar_r
      Community Hero

      Nice to hear :),

       

      Configuration setup of TestData sheet is bit difficult for the new users. I'm planning to create a video which will help to understand the Test data sheet soon!.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Nice work, shankar_r!  

         

        Any consideration in modifying the extension to work with different data sources like SQL or CSV?  Each tab on that spreadsheet would be a different CSV file or a different SQL table.

         

        Either way, good stuff, man!

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Did you download and install the Script Extension?  That is required.

  • Hi shankar_r I'm not able to add DataDrivenFramework script extention into my Testcmplete path due to access  please provide javaScript code for DataDrivenFramework

     

    Thanks

    Ravi

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      You can configure your TestComplete installation to point to an additional directory to use for Script Extensions.  Tools | Options | Engines | Script Extensions.  So, while you might not have access to put a file in the Program Files path, you can install it into a different directory.

       

      That said...

      ....  there is no "out of the box" framework for running automation for Data Driven for TestComplete.  There are MANY ways of doing the same general concept in TestComplete.  You can use Shankar's framework... or mine... or someone else's... or write one yourself.  It's a matter of using and/or adapting what works best for you in your situation.  

      As for taking Shankar's and extracting it for your own use...  That's up to Shankar.   He wrote this framework and, I'm assuming, he put a LOT of time, work, effort, and resource into it.  By packaging it in a Script Extension, he somewhat protects his work.  To just post the raw code openly means someone can benefit from his work... and he won't necessarily get credit.  So... I'll leave it up to him.

  • shankar_r while running your sample  login function script,im getting below Errors

     

    Error occured in fn_getExcelObject function , Error Description: The needed data source driver is not installed or is not configured properly.
    To read data, install the 64-bit version of Microsoft Office 12.0 Access Database Engine OLE DB Provider. It is part of Microsoft Access Database Engine 2010 Redistributable. You can find it on the Microsoft website. Alternatively, you can try using the 32-bit version of TestComplete 7:32:56 Normal

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      RaviKumar98:
      Based on the text of error messages, my guess is that you are starting 64-bit flavor of TestComplete using the shortcut from the desktop.

      Try to start 32-bit flavor from the <TestComplete>\Bin folder and check if this change something.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      RaviKumar98 wrote:

      shankar_r while running your sample  login function script,im getting below Errors

       

      Error occured in fn_getExcelObject function , Error Description: The needed data source driver is not installed or is not configured properly.
      To read data, install the 64-bit version of Microsoft Office 12.0 Access Database Engine OLE DB Provider. It is part of Microsoft Access Database Engine 2010 Redistributable. You can find it on the Microsoft website. Alternatively, you can try using the 32-bit version of TestComplete 7:32:56 Normal


      Please read the following and follow the instructions.

      https://community.smartbear.com/t5/TestComplete-General-Discussions/Warning-Windows-updates-break-interaction-with-xls-files-from/m-p/152267#M28117

    • shankar_r's avatar
      shankar_r
      Community Hero

      RaviKumar98 Please keep in mind this ScriptExtension was created before 12.4* release hence it may not be comfortable without making change in the code for new releases. 

      • RaviKumar98's avatar
        RaviKumar98
        Contributor

        shankar_r I have fixed above issue but now I'm getting new Error.

         

        Error occured in Master function , Error Description: Provider cannot be found. It may not be properly installed. 9:25:22 Normal

        please help me to resolve it

         

        Thanks

        Ravi

    • shankar_r's avatar
      shankar_r
      Community Hero

      It is default to Project Path. If you want you can customize the Script Extension.

       

      For this, 

      below line have to modified to change the testdata path which will be in line no: 365

       

      Project.Variables.gTestDataPath = Project.Path + "TestData.xls"; 

      • RaviKumar98's avatar
        RaviKumar98
        Contributor

        can you tell which file i need to change customize Test-data path.Because i'm not able to find line no 365 in any file.

         

        Thanks,

        Ravi