Here is my Code:au

package Mypackage;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class jh{
    WebDriver driver;
    public void loginjh(String loginId ,String password)throws InterruptedException {
        WebDriver driver = new FirefoxDriver();
         driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
         driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    public void tearDown()

public Object[][] TestData()

***Excel Dataconfig config = new Excel Dataconfig("Excel Path");

int rows = Config.getRowcount(0);

Object[][] data = new Object [rows][2];
for(int i=o;i<rows;i++)
return data;
  • Can you please explain this line ? ` ***Excel Dataconfig config = new Excel Dataconfig("Excel Path");`
    – Sagar007
    Feb 5, 2018 at 8:06
  • i want to read data from excel file
    – Rahul
    Feb 5, 2018 at 8:27
  • 1
    But as per my knowledge. Java do not allow this syntax . Please check your code. Also send me the link that you follow for read excel file.
    – Sagar007
    Feb 5, 2018 at 10:11
  • Your syntax is wrong. Fix it and get back with the issues if any.
    – Alexey R.
    Feb 5, 2018 at 12:27
  • Please paste you error/exception completely overhere first. Then only once can answer after seeing the root cause Jul 9, 2018 at 11:09

2 Answers 2


You start and closed your loginjhmethod. At TestData method you don't have any parenthesis and no entry data (empty at quotation marks)


Use this following code for reading the values from Excel sheet:

@DataProvider(name = “Rahul”)

public Object[][] readExcel(String sheetName) throws InvalidFormatException, IOException {

//Load the Excel File

File src = new File(“./data/”+sheetName+”.xlsx”);

//Open the Book

XSSFWorkbook wb = new XSSFWorkbook(src);

//Go to Sheet

XSSFSheet sheet = wb.getSheet(“Sheet1”);

//Row Count

int rowCount = sheet.getLastRowNum();


//Column Count

int column = sheet.getRow(0).getLastCellNum();


Object[][] data = new Object[rowCount][column];

// Row – for

for (int i = 1; i <=rowCount; i++) {

XSSFRow row = sheet.getRow(i);

//Column – for

for (int j = 0; j < column; j++) {

XSSFCell cell = row.getCell(j);


data[i-1][j] = cell.getStringCellValue();



return data;



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.