Request to add code code for initialising xls reader i reader at run time | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos

Selenium Training Forum

Request to add code code for initialising xls reader i reader at run time

viijjii Post on 09/10/2018

Hi ,

Could you please update the code here . It will be really helpful




demo Reply on 11/10/2018

Its being done today

Mohammed Reply on 11/10/2018

Sure will share the code , I would like to know where the GC overload limit is faced i updated the code for eclipse first then I got the same in jenkins 
So after updating it finally its working 
Please find the updates below hope it helps.

@vijjii - can you please let me know where you found the GC overload , was it in jenkins or in eclipse while running your test suite.?

Hi Vijjii,
Let me explain in detail
In Ashish thakur framework he is creating the object of the XLS_Reader and passing in the data provider, so if you want to make sure GC overhead is not faced do the following 
Do not create the object of the XLS_Reader in each class at global level or in the Base class (Just avoid creating the object) this helped me 

Test case will look like

public class TC_0001_CP_identifications_Verify_PageTitle extends TestBase {
DataUtil dataUtil = new DataUtil();

String testName = "TC_0001_CP_identifications_Verify_PageTitle";

public Object[][] getDataForTestCaseName() throws FileNotFoundException {
return dataUtil.getDataForTestCaseName(ConstantValues.DATA_XLS_PATH_PORTAL, testName); // here we will pass the path of the XLS_Reader instead of object.

I changed the methods in DataUtil class from static to nonstatic 

Step 2: In data util class create the object of xls like given below
public class DataUtil{
static Xls_Reader xls =null; // global object kept to null

public Object[][] getDataForTestCaseName(String excelLocation, String testCaseName) throws FileNotFoundException {

Object[][] data = null;
Xls_Reader xls = new Xls_Reader(excelLocation);

String sheetName = ConstantValues.TESTDATA_SHEET;

Also for other methods use 
public boolean isTestExecutable(String excelLocation, String testCaseName) {
xls = new Xls_Reader(excelLocation);


IF you cannot understand or do not have time to modify all the scripts then just create the object of the XLS_Reader in the Base as static and extend the base class to all other classes this is temporary fix
public static Xls_Reader xls_chbackoffice = new Xls_Reader(ConstantValues.DATA_XLS_PATH_CHBACKOFFICE);

I have tried both the ways and this works , there is no issue or bug in the XLS_Reader Class its only how we create the object of it and at what point.

Mohammed Reply on 11/10/2018

@Ashish - Please let me know if this is correct , currently this is working fine for me 
Do let me know if i can enhance the performance to this as well so that i can also update in my project

viijjii Reply on 12/10/2018

Thanks mohammed