Quality Testing

Quality is delighting customers

=======================

application.properties

=======================

URL=http://google.com

=====================

ReadFleData Java Class

=====================

public class ReadFileData

{
public static String AppData() 

{

File file = new File("C:\\Users\\eclipse-workspace\\practice\\config\\application.properties");   

FileInputStream fileInput = null;

try

{

fileInput = new FileInputStream(file);

} catch (FileNotFoundException e)

{

e.printStackTrace();

}

Properties prop = new Properties();

//Load properties file

try

{

prop.load(fileInput);

} catch (IOException e)

{

e.printStackTrace();

}

return null;
}
}

=====================================

Calling read file data from another class:

=====================================

public class Google

{

ReadFileData read = new ReadFileData();

driver.get(read.AppData(????));
}

Views: 61

Reply to This

Replies to This Discussion

Hi,

Reading data from properties file is not difficult and following method being used by automation experts providing automation and qa services:

Code snippet:
static Properties property = new Properties();
property.load(new FileInputStream("properties file path"));

public String getvalue(String var) {

property.getProperty(var);

}

Properties file should have the data like following:
SearchText=TestText // Where SearchText is variable name and TestText is the String to pass

So, if we want to pass text "TestText", then simply we can call getvalue function:
getvalue("SearchText");

Thanks,
Anand

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service