Properties File in Selenium



In eclipse create a file with the name config.properties


  • Property file is used for configuration purpose.

  • This is not for test data, but for configuration data.

  • This file is loaded at start while configuring any application

  1. All methods of this class are synchronized. So it is thread safe class.

  2. It has been since from jdk 1.0.

  3. It is the subclass of HashTable.

  4. It stores the key-value pair, but both as a string.

  5. It can used to get property value based on property key.

  6. It can be used to get properties of the system.

  7. It provides easy maintenance.

  8. It can be used to get properties from an xml file or to store data in xml file.

Also XML file is created as below in D drive.

Step 1: Create a properties file in ‘D drive’ as shown below and save with the name login. properties [make changes in the program according to the location of the path you choose]


Step 2: Write below given program to read a file. In this program, we read one of the property names i.e. ‘username’.


Step 3: Run the program and see the output.

Note: If you look at the above program in Java program, no values are used so that in the near future even if username needs to be changed, it can be changed in the properties file itself which can also be done by a non-technical person.