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.
TEST:
public class StandardProductPricingTest{
@BeforeTest
public void setUp() {
Page.initConfigurationAndLogin();
}
@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();
home.searchProduct(product);
galleryPage.clickOnThePicture();
String price = pdPage.readPrice();
}
}
DATA PROVIDER:
public class Utilities extends Page {
@DataProvider(name = "readData")
public Object[] getData() {
String data = excel.ReadCellData(1, 0);
return new Object[] {data};
}
@DataProvider(name="writeData")
public Object[] writeData(String price){
String sheetName = "standardproduct";
String data = excel.getCellData(sheetName, 0, 2);
System.out.println(data);
int rowCount = excel.getRowCount(sheetName);
System.out.println("total rows: " + rowCount);
excel.setCellData(sheetName, "PDP Price", 2, price);
return new Object[] {price};
}
}
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
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP