Skip to content

Instantly share code, notes, and snippets.

@pragmatictesters
Created April 19, 2025 07:42
Show Gist options
  • Save pragmatictesters/769ae71727897fd7f54799101e7aa6c1 to your computer and use it in GitHub Desktop.
Save pragmatictesters/769ae71727897fd7f54799101e7aa6c1 to your computer and use it in GitHub Desktop.
Reading values from a property file
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