mercredi 8 juin 2016

Dataprovider not able to pass data to method

I have to pass 4 values from excel sheet to data provider and from there to method.I am able to fetch data from excel sheet but not able to provide data to method,

data :- Column 1 Column 2 column 3 column 4
1.E-coupons - Loyalty card,ID type,Others,No. of e-coupons issued 2.E-coupons - Loyalty card,Member profile,Registration status,No. of e-coupons redeemed 3.E-coupons - Loyalty card,Member profile,Gender,No. of e-coupons expired 4.E-coupons - Loyalty card,Member profile,Marital status,No. of e-coupons issued

pls help me in this.thanx in advance

enter image description here @Test (dependsOnMethods={"compa"} , dataProvider="Testdata") public void AnalysisEcoupon(String analtype, String dim1,String dim2,String fact) throws Exception{

      System.out.println("analysis ");
      WebElement moveonmenu = driver.findElement
                (By.xpath("/html/body/div[5]/div[5]/div[2]/div/div[4]/div/div/select"));
     action.moveToElement(moveonmenu); 
     action.perform();

     Select dropdown = new Select(driver.findElement(By.id("cube_id")));//year selection
    dropdown.selectByVisibleText(analtype);


        Thread.sleep(4000);

      driver.findElement(By.id("axis_id")).sendKeys(dim1);
      Thread.sleep(4000);
      driver.findElement(By.id("dimension_id")).sendKeys(dim2);
      // driver.findElement(By.id("fact1_id")).sendKeys("No. of e-coupons issued");
      driver.findElement(By.id("fact1_id")).sendKeys(fact);
      Thread.sleep(4000);
      driver.findElement(By.id("fact2_id")).sendKeys(fact);;
      Thread.sleep(4000);
      driver.findElement(By.id("one_period_radio")).click();


         }


@DataProvider(name="Testdata")
    public Object[][] TestDataFeed() throws Exception
{


        File src=new File("/home/user/Documents/sheet1.xlsx");

        FileInputStream fis=new FileInputStream(src);

        wb =new XSSFWorkbook(fis);

    // load sheet in my case I am referring to first sheet only

        sh1= wb.getSheetAt(0);

    // get number of rows so that we can run loop based on this
    numrow=  sh1.getLastRowNum();

    System.out.println("row count:"+numrow);


    // Create 2 D array and pass row and columns
    Object[][] analdata=new Object[numrow][4];

    // This will run a loop and each iteration  it will fetch new row
    for(int i=0;i<numrow;i++){

    analdata[i][0] =sh1.getRow(i).getCell(i).getStringCellValue();
    analdata[i][1]=sh1.getRow(i).getCell(i+1).getStringCellValue();
    analdata[i][2] =sh1.getRow(i).getCell(i+2).getStringCellValue();
    analdata[i][3] =sh1.getRow(i).getCell(i+3).getStringCellValue();


     System.out.println("strings are :" +analdata[i][0]+","+analdata[i][1]+","+analdata[i][2]+","+analdata[i][3]);
    }

    // Return 2d array object so that test script can use the same

    System.out.println("return proceed");

    return analdata;


    }

}

Aucun commentaire:

Enregistrer un commentaire