testNG, Java: How to combine a few Data Providers in one test?

Software Quality Assurance & Testing Asked by Beti on August 12, 2020

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 splited that into 2 data providers ("readData" and "writeData"), however I am 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?
Thank you in advance.


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};


One Answer

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

Correct answer by viren tiwari on August 12, 2020

Add your own answers!

Related Questions

Random pause of 2 to 5 seconds between requests Jmeter

1  Asked on November 28, 2021 by denis-filatov


Script timeout in Protractor

2  Asked on November 21, 2021 by ingridd-brito


Find button class with Selenium on Python

2  Asked on November 19, 2021 by nizariansyah-agung


Should Testers be called QA?

4  Asked on October 25, 2021 by jainam


Problem implicit wait with wait.until

1  Asked on October 25, 2021 by markus-pallasch


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP