In the provided test I need to read the data from the cell in Excel and it works.

I would also like to add the functionality to store the price of the product in another cell in the Excel.

I've split, that into 2 data providers ('readData' and 'writeData'), however I'm unable to add the second data provider to the test or I don't how to do that.

Could you please advise how to combine both of them in 1 test?


public class StandardProductPricingTest{

public void setUp() {

@Test(dataProviderClass = Utilities.class,dataProvider = "readData")
public void standardProductPricingTest(String product) throws InterruptedException, IOException {
    HomePageActions home = new HomePageActions();
    GalleryPageActions galleryPage = new GalleryPageActions();
    PDPageActions pdPage = new PDPageActions();

    String price = pdPage.readPrice();


public class Utilities extends Page {

@DataProvider(name = "readData")
public Object[] getData() {

    String data = excel.ReadCellData(1, 0);

    return new Object[] {data};

public Object[] writeData(String price){

    String sheetName = "standardproduct";
    String data = excel.getCellData(sheetName, 0, 2);

    int rowCount = excel.getRowCount(sheetName);
    System.out.println("total rows: " + rowCount);

    excel.setCellData(sheetName, "PDP Price", 2, price);

    return new Object[] {price};


  • 2
    A data provider is aimed at providing test data, only one can be set for each @Test. Why don't you add a call to this writeData function at the end of the test or on the teardown method? Jul 22, 2020 at 12:41

1 Answer 1


Data Providers are use to pass the Test-Data into the @test .Please create a java member function to write the excel and call directly to your @test instead of using it in /as data provider

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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