Selenium 如何读取conf.properties文件?

Selenium 如何读取conf.properties文件?,selenium,selenium-webdriver,Selenium,Selenium Webdriver,我想读取conf.properties文件,但不是通过提供硬编码路径来读取,所以如何才能读取它?我使用了下面的行,但是它写了一个空值,但是路径是正确的 InputStream InputStream=ReadPropertyFile.class.getResourceAsStreamconfiguration/conf.properties 假设您的项目中有配置文件夹&该文件夹包含conf.properties 在函数中使用以下命令- String projdir = System.getPro

我想读取conf.properties文件,但不是通过提供硬编码路径来读取,所以如何才能读取它?我使用了下面的行,但是它写了一个空值,但是路径是正确的


InputStream InputStream=ReadPropertyFile.class.getResourceAsStreamconfiguration/conf.properties

假设您的项目中有配置文件夹&该文件夹包含conf.properties 在函数中使用以下命令-

String projdir = System.getProperty("user.dir");
String propfilepath = projdir+"\\config\\"+"conf.properties";
Properties p = new Properties();
p.load(new FileInputStream(propfilepath ));

String value  = p.getProperty("test");
System.out.println(value); // It is returning me a value corresponding to key "test"