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

Commonly occurred exceptions you know in WebDriver
WebDriverException NoAlertPresentException NoSuchWindowException NoSuchElementException TimeoutException

Selenium waits
In Selenium web driver, the biggest challenge is to synchronize your script with the Web application under test. To make this synchronization work, we have concept of waits. Although we can use Thread.sleep()...

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...

TestNG
TestNG Concepts TestNG: TestNG is an automation framework to run the test cases, test suites and do parallel testing. It is an advanced version of Junit. It consists of many features like annotations,...

Setting Up Environment For Selenium Webdriver
1. Installation of Selenium IDE: i. Launch Firefox and navigate to https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/ . Click on Add to firefox. ii. Wait until Firefox completes the download...
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