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
6 Asked on January 6, 2022 by mercfh
3 Asked on January 6, 2022 by sachintha
3 Asked on January 4, 2022
automated testing scrum test design test management test planning
1 Asked on January 2, 2022 by amaze_rock
4 Asked on December 31, 2021
2 Asked on December 28, 2021 by sreelakshmi
8 Asked on December 26, 2021 by jarvis-frost
1 Asked on December 26, 2021
3 Asked on December 26, 2021 by tyrel-craig
automated testing jira katalon test management test planning
1 Asked on December 26, 2021 by therealtealeaf
1 Asked on December 24, 2021 by mornon
2 Asked on December 22, 2021
2 Asked on December 14, 2021
3 Asked on December 12, 2021 by koushick
1 Asked on December 12, 2021
automated testing azure devops c performance testing selenium webdriver
1 Asked on December 10, 2021
3 Asked on December 6, 2021 by ferosh-khan
8 Asked on December 2, 2021 by helping-hands
2 Asked on December 2, 2021
Get help from others!
Recent Answers
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP