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

What is Selenium?
In simple words, Selenium automates browsers. It is a robust set of tools that supports rapid development of test automation for web-based applications. Cool Features: Works on every system,...

Selenium Web Driver commonly used method
Navigation Loading a web page in a current browser window driver.get("www.google.com") driver.navigate().to("www.google.com") driver.navigate().to("www.google.com") Move back & forward Driver.Navigate().Back() Driver.Navigate().Forward() Refresh...

How to refresh a page without using contextclick?
1. Using sendKeys methoddriver.findElement(By.id("firstname-placeholder")).sendKeys(Keys.F5);2. Using navigate.refresh() methoddriver.navigate().refresh();3. Using navigate.to() methoddriver.navigate().to(driver.getCurrentUrl());4....

Difference between driver.close() and driver.quit () method
close () -By using this command, we can close the current browser or page. quit() - By using this command, we can shut down the web driver instance or destroy the web driver instance(Close all the windows).

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