How to call not static things inside static methods | Selenium Forum
M
Posted on 30/12/2016
In POM-Module23, we created two files ExtentManager.java and DataUtil.java.
In both these file we were providing values using FBConstant.java, i need to read values from propeties file but these classes have static methods.

Exmple in ExtentManager

public static ExtentReports getInstance() {
if (extent == null) {
Date d=new Date();
String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
........................................................................................
String reportPath ="D:\\reprots\\" +fileName;
...........................................................................................
extent = new ExtentReports(reportPath, true, DisplayOrder.NEWEST_FIRST);

now i want to read the report file from properties file. but when i am using (prop.getProperty("ReprotPath"), its not working as getInstance() is static and calling the getProperty with obj name is not allowed.

same is happening with DataUtil.java when i am reading the name of sheet from properties file as getData is static

public static Object[][] getData(Xls_Reader xls, String testCaseName){
..........................................................................................
String sheetName=FBConstants.TESTDATA_SHEET;
............................................................................................

In Tutorial you wer taking the name from FBConstants file and declare these var as static, but to read values from properties files, we have to call them using obj.

Suggest a solution for the same.

M
Replied on 30/12/2016

come on skype right now. my id is qtpselenium1.