Framework configuration – Read properties file

settings_file-512  So a property file would be basically a key value pair. We need one file that would contain all properties that we need (type of driver for now) and we would also need some code to read the values from this property file when needed.
Let us create a properties file, right inside the src folder. We will name it
and add a browser property inside it. It should look like the following.

browser= firefox

Almost automation framework have configuration file to set test environment such as: browser, url. Beside, someone use properties file to store xpath,css or test data for their framework.

And java have methods to support read/write properties file. Below is one of example for it:

import java.util.Properties;

* Created by HaDo on 2/14/17.
public class PropertyReader {
Properties properties = new Properties();
InputStream inputStream = null;
public PropertyReader() {
private void loadProperties() {
try {
inputStream = new FileInputStream("src/");
} catch (IOException e) {
public String readProperty(String key) {
return properties.getProperty(key);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.