Created
April 19, 2025 07:42
-
-
Save pragmatictesters/769ae71727897fd7f54799101e7aa6c1 to your computer and use it in GitHub Desktop.
Reading values from a property file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pragmatic.selenium.util; | |
| import java.io.FileInputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.Properties; | |
| public class ConfigReader { | |
| private static Properties properties = new Properties(); | |
| static { | |
| try { | |
| InputStream input = | |
| new FileInputStream("src/test/resources/config.properties"); | |
| properties.load(input); | |
| } catch (IOException e) { | |
| throw new RuntimeException(e); | |
| } | |
| } | |
| public static String get(String key){ | |
| return properties.getProperty(key).trim(); | |
| } | |
| public static String getBaseURL(){ | |
| return get("BASE_URL"); | |
| } | |
| public static String getBrowser(){ | |
| return get("BROWSER"); | |
| } | |
| public static int getTimeout(){ | |
| String timeout = get("TIMEOUT"); | |
| return Integer.parseInt(timeout); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment