Sunday, 20 January 2013

Properties file: Reading Properties files

First you need to create  iam.properties file in our webdriver project


name=yogi
college=crazyfun
age=22

browser=firefox
testSiteName=xyz.com
environment=UAT
//**********************



public class ReadProperties {


public static void main(String[] args) throws IOException {

FileInputStream fs = new FileInputStream("F:\\Workspaces\\..\\..\\iam.properties");
Properties prop = new Properties();
prop.load(fs);

System.out.println(prop.getProperty("college"));
System.out.println(prop.getProperty("company"));
System.out.println(prop.getProperty("name"));


}

}

1 comment:

  1. Hi,

    Can you please tell us how above script will run on firefox browser ?
    I means how we can trigger firefox through properties file ?

    Thanks,

    ReplyDelete