How to implement Xls Reading in Test NG in @Test in Test NG? I know how to read from xls, but dont know to implement and parameterize it. in @Test
I need to run the @Test for 3 parameters which read from Xls.
//My working code to read from xlsx.
Xls_Reader workbook = new Xls_Reader("C:\\Users\\kapil.kuriakose\\Desktop\\JAVA\\TestData_dice.xlsx");
int rNum = workbook.getRowCount("Dice");
System.out.println("Rows:"+rNum);
for(int i=2; i<=rNum; i++) {
String tool_typed = workbook.getCellData("Dice", 0, i);
String tool = workbook.getCellData("Dice", 1, i);
String location_typed = workbook.getCellData("Dice", 2, i);
String location = workbook.getCellData("Dice", 3, i);
System.out.println(tool_typed+ "---"+tool+"---"+ location_typed +"---" +location);
}
//============================below is the @Test code for a test case. where I should implement and how?
public class Dice_Pagination_Xls {
//String tool_typed = "Selenium";
//String tool = "selenium";
//String location_typed="Phoenix";
//String location = "Phoenix, AZ, USA";
WebDriver driver = new FirefoxDriver();
@Test
public void searchJobs(String tool_typed, String tool, String location_typed, String location ) throws InterruptedException {
Xls_Reader workbook = new Xls_Reader("C:\\Users\\kapil.kuriakose\\Desktop\\JAVA\\TestData_dice.xlsx");
int rNum = workbook.getRowCount("Dice");
System.out.println("Rows:"+rNum);
for(int i=2; i<=rNum; i++) {
tool_typed = workbook.getCellData("Dice", 0, i);
tool = workbook.getCellData("Dice", 1, i);
location_typed = workbook.getCellData("Dice", 2, i);
location = workbook.getCellData("Dice", 3, i);
System.out.println(tool_typed+ "---"+tool+"---"+ location_typed +"---" +location);
}
System.setProperty(SystemProperty.BROWSER_LOGFILE, "null");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.navigate().to("https://www.dice.com/");
Instructor
Ashish Thakur Replied on 25/11/2019
As you proceed and look at Selenium WebDriver Framework Tutorials then you will be able to understand and relate how to do the XLS_Reading
You need to use @Dataprovider and hastable