JAVA Code to Create an Excel File in Relative Path

Using excel files is one of the most common method for test data and other types of data management. The java code to create an Excel file is very easy and most of the code is self explanatory. Lets have a look at the same:
Eclipse needs to be pointed to the required JAR files in order to make it work with various functions provided by apache. Read more on Apache at it’s official website: Apache POI


The poi(s) need to be added to the project before running this code. Different versions may or may not support all functions and need to be worked with accordingly. Below is the snapshot of POI(s) used in my program. They can be downloaded from

Eclipse - Java Build Path
Eclipse-Java Build Path


Below is the JAVA class which creates an excel file in the “Relative Path”.

The code first checks for the directory “temp” at the relative path and creates if it does not exists.

Next, the excel file with three columns namely – “First Name”, “Last Name” and “Country”. If the file already exists, the code overwrites the same.

The code prints following on console when run the first time:
Directory already exists!
Excel File created: C:FunctionalTestAutomationproject_TestProject1tempMyExcelFile.xlsx
When we run the code second time, the console is as below:
Directory already exists!
Excel File created: C:FunctionalTestAutomationproject_TestProject1tempMyExcelFile.xlsx

Tada! That was one of the ways to write JAVA code and create an Excel file at the relative path. Hope it helped.

Automation Framework: Keyword Driven Framework

Keyword Driven framework is also known as table-driven or action-word driven framework. In this framework, an application map is defined including it’s objects, components, actions and an expected value for each component. It requires very deep knowledge of applications and automation testing expertise.

Keyword-driven tests look very similar to manual test cases. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test. In this method, the entire process is data-driven, including functionality.


  • The Detail Test Plan can be written in Spreadsheet format containing all input and verification data.
  • Application, language, tool independent.
  • Takes time, but most successful in long run.

  •  The Development of “customized” Functions and Utilities requires proficiency in the tool’s Scripting language.
  • Takes lot of time iitially.

Automation Framework: Data Driven Framework

Data Driven Framework is a systematic approach to test an application. In data-driven framework test input and output values are read/write from/to data files (Mostly Excel files) and are loaded into variables in captured or manually coded scripts. In this framework, variables are used for both input values and output verification values. Navigation through the program, reading of the data files, and logging of test status and information are all coded in the test script.

Merits of Data Driven Framework:-

  • Scripts may be developed while application development is still in progress.
  • Utilizing a modular design, and using files or records to both input and verify data, reduces redundancy and duplication of effort in creating automated test scripts.
  • If functionality changes, only the specific “Business Function” script needs to be updated.
  • Data input/output and expected results are stored as easily maintainable text records.
  • Functions return “TRUE” or “FALSE” values to the calling script, rather than aborting, allowing for more effective error handling, and increasing the robustness of the test scripts. This, along with a well-designed “recovery” routine, enables “unattended” execution of test scripts.

Demerits of Data Driven Framework:-

  • Requires proficiency in the scripting language used by the tool (technical personnel).
  • Multiple data-files are required for each Test Case. There may be any number of data-inputs and verifications required, depending on how many different screens are accessed. This usually requires data-files to be kept in separate directories by Test Case.
  • Tester must not only maintain the Detail Test Plan with specific data, but must also re-enter this data in the various required data-files
  • If a simple “text editor” such as Notepad is used to create and maintain the data-files, careful attention must be paid to the format required by the scripts/functions that process the files, or script-processing errors will occur due to data-file format and/or content being incorrect

Automation Framework: Linear Automation framework

Linear framework is the most simple of all the frameworks. Linear framework has individual scripts for each test case and is executed individually. It depicts the basic record and playback approach. Linear Framework is suitable to convert small to medium size manual scripts into equivalent automation scripts – one to one basis.

Advantages of Linear framework:-

• Quick development – There is little planning or consideration of the various Quality Attributes when creating Linear scripts. As the scripts are created by recording, it does not require much effort.

• Doesn’t need through knowledge of the tool – Test automation typically requires through knowledge of the automation tool features and languages supported. One should also be aware of how the tool interacts with the application under test. The use of Record and Playback in the creation of Linear scripts dynamically creates code that replicates actions performed in the application.

• Script Independence – The scripts are independent of each other.

Disadvantages of Linear framework:-

• Issues in Playback – As the linear framework rely heavily on Record and playback, the recorded scripts do not playback properly for various reasons.

• Duplicity of work – Linear framework proceeds on individual scripts, thus reuse feature is not used in it. If some scripts require same action to be performed, it would again be recorded in the test.

• Scripts are difficult to read – As the script is auto generated, it has no comments and thus makes it difficult to read and interpret.

Automation Framework

A test automation framework can be defined as a compilation of assumptions, concepts, and practices that provide support for automated software testing.

Framework comprises support programs, processes, code libraries etc to help develop and glue together the different components in a project.

Physically, Frame work is nothing but a collection of folder structure and placing all files into corresponding folders.

Problems with Record/Playback Process:-

A general conception about automation tools is that they can be used easily by using their record and playback feature. The process followed in record and playback (also called as Capture/Replay) approach is:-

  • Record the user actions using the capture/record feature of the automation testing tool. 
  • It results in an auto generated script. 
  • Complete the test cases by adding verification points in the script.  
  • Add delay and wait state points where the different actions need to be synchronized. 
  • Playback the scripts and log the results in a test management tool. 

The above process results in following issues:-

  • The script contains hard coded values which must be changed every time there is some change in the Application. 
  • The scripts are not reliable. Even if the application does not change, the scripts often fail on replay because of unhandled scenarios which were not recorded. 
  • If the tester makes an error entering data, etc., the test must be re-recorded 
  • If the application changes the test must be re-recorded. 
  • This method turns out to be costly (time consuming) in long run.