0

I am trying to execute a script for login into webpage.Can any1 help me solve dis problem?

I am getting below error:-

The data provider is trying to pass 7 parameters but the method
efgh.DataDriven#login takes 2

public class DataDriven {

    public WebDriver driver;

    @Test(dataProvider ="testdata")
    public void login(String username, String password){

        driver=new ChromeDriver();
        driver.get("https://pos.lycamobile.es/Login/login.aspx?lang=ES");
        driver.findElement(By.name("UserName")).sendKeys(username);
        driver.findElement(By.name("Password")).sendKeys(password);
        driver.close();
    }

    @DataProvider(name = "testdata")
    public Object [] [] readExcel() throws BiffException, IOException {

       File f =new File("D:\\Users\\sarsiddi\\Documents\\DataSheet.xls");
       Workbook w = Workbook.getWorkbook(f);
       Sheet s= w.getSheet("lycadata");

       int rows = s.getRows();
       int columns = s.getColumns();
      // System.out.println(rows);
     // System.out.println(columns);   

        String inputData[] [] = new String [rows] [columns];
        for (int i=0; i<rows; i++){
            for (int j=0; j<columns; j++){
                Cell c = s.getCell(j, i);
                inputData [i][j] = c.getContents();
                //System.out.println(inputData[i][j]);
            }     
        }
        return inputData;
    }
}
sarfaraz
  • 15
  • 7

1 Answers1

0

Your dataprovider wants to give all 7 parameters to the test, but Login takes only 2.

To fix this there are 2 options.

  1. Add all 7 parameters to the login method. Currently you have username and pw

  2. Return only 2 parameters to the dataprovider.

If you only plan to use those 2 parameters in that test then, I would remove the other parameters from the excel sheet. Or create another sheet for login only.

Madis Kangro
  • 293
  • 3
  • 12
  • Can you share an example as how to do that, Please – sarfaraz Aug 08 '16 at 12:37
  • public void login(String username, String password, String three, String four, String five, String six, String seven) This will add the parameters that It gets from the dataprovider to the test. – Madis Kangro Aug 08 '16 at 12:38