UrbanPro
true

Learn Selenium from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How to Read Data From Property File

S
Sarthak C.
19/12/2019 0 0

1. Create a property file using New > File > Given name - like config.properties (it must be saved with .properties).

2. Add data in config.properties like:

browser = chrome

environment = qa

3. Add a class to read the property file (see below class)

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class ReadingProperties {

static FileInputStream fis;
static Properties prop;

public static String getValueOfPropertyFile(String value) throws IOException {

fis = new FileInputStream("-------Path of the property file-------");
prop = new Properties();
prop.load(fis);

return prop.getProperty(value);
}

}

4. Where you want to read the data just call - ReadingProperties.getValueOfPropertyFile("----pass the key which you want from property file").

The function will return to the value of that key.

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Why we declare WebDriver driver = new FirefoxDriver(); and not FirefoxDriver driver = new FirefoxDriver();
Here, List or WebDriver is an Interface - a contract or set of rules created for implementing class.So, in Java, we cannot create an instance of an interface. ieI cannot say List list = new List();But...

Difference between find element () and findelements () in webdriver
findElement Find the first element within the current page using the given "locating mechanism". Returns a single WebElement. findElements Find all elements within the current...

Free selenium video tutorial
Hi All, Hope you are doing good. We uploaded few videos on Selenium components like IDE, RC and Webdriver on youtube channel you can watch them for free of cost. Kindly search with below link: ...
S

How to toggle b/w frames in webdriver
driver.switchTo().frame() method takes one of the three possible arguments: A number - Select a frame by its (zero-based) index. A name or ID - Select a frame by its name or ID. A previously found...

Use JavascriptExecutor to do many cool things in Selenium
Javascript is a compelling language to interact with DOM. So it would make sense to use Javascript to run in the browser using Selenium whenever there is no other way to work on a particular element using...
X

Looking for Selenium Classes?

The best tutors for Selenium Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Selenium with the Best Tutors

The best Tutors for Selenium Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more