You are on page 1of 2

Framework concepts

------------------

Framework Concepts -properties file

purpose-Store website details like browser


url etc

properties file

Browser
url of application

project configuration data

Browser Browser Browser Browser


url url url url

class1 class2 class3 class4

To avoid creating browser and url in every class

Properties file

Browser
url

class1 class2 class3 class4

All classes refers to properties file which have


browser and url

how this classes follow to retrieve data from properties


file

new>proj>java proj>propproj
propproj>new>folder>config
config>new>file>EmpDetails.properties
open properties fie:
Name=Ravi
Place=bangalore

src>new>class>Demo
main()>
google>java 8 api
ctrl+f properties
methods:load(inputstream),getproperty we will use
represent properties file as a file
file propfile=new file("config//EmpDetails.properties");
fileinputstream fis=new fileinputstream(propfile);
properties prop=new properties();
prop.load(fis);//load takes inputstream//it will
load empdetails.properties file

s.o.p(prop.getproperty("Name"));//Ravi
s.o.p(prop.getproperty("Place"));//bangalore
Demo>run>o/p:
Ravi
Bangalore

Now selinium project


new>proj>seliproj
seliproj>new>folder>libraries
-----------------------------
libraries>paste selinium jars,configure it
src>new class>demo>
main()>
proj>new>folder>config
config>new>file>projectDetails.properties
propertiesfile:
Browser=chrome
URL=google.com

class>
main>
File fi=new file("properties file");
properties prop=new properties();
fileinputstream fis=new fileinputstream(fi);
prop.load(fis);
proj>new >folder>divers>paste exes
String browsername=prop.getproperty("Browser");
webdriver driver=null;
if(browsername.equals("firefox")
{
Sys.setprop("","");
driver=new
}
else if(browsername.equals("chrome")
{
Sys.setprop("","");
webdriver driver=new
maximize
}
driver.get(prop.getproperty("URL"));

run>
it goes to google.com

change chrome to firefox if want to run in firefox

adv:can change details in single location

You might also like