Data Driven Framework in Selenium-Part 2: Read data from Excel with TestNG DataProvider (Apache POI)

preview_player
Показать описание
#seleniumwebdriver #datadriven #apache
+ How to read data from Excel with TestNG DataProvider using Apache POI
+ Data Driven Framework in Selenium

▬▬▬▬▬▬ In this Video ▶️ ▬▬▬▬▬▬
TestNG plugin to Selenium: TestNG is a unit test framework that gives you control on your automation. Ex: you can run specific 200 testcase as a SmokeTest out of 500 test case, Set a test execution preference and so on.

Select TestNG+Next +finished+ Restart Eclipse.
Data Driven Testing in Selenium: Is a test automation framework that stores test data in a table or spreadsheet format.

This allows automation engineers to have a single test script that can execute tests for all the test data in the table.

POI stands For “Poor Obfuscation Implementation”. Apache POI is an API provided by Apache foundation which is a collection of different java libraries. This libraries gives the facility to read, write and manipulate different Microsoft files such as excel sheet, power-point, and word files.

*****LATEST NOTE******
1) poi
2) poi-ooxml

Note: Class HSSFDateUtil is deprecated.
Use DateUtil instead.

▬▬▬▬▬▬ Useful Links 🛠 ▬▬▬▬▬▬

▬▬▬▬▬▬ Connect with us 👋 ▬▬▬▬▬▬

🌟 Please click on LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
Рекомендации по теме
Комментарии
Автор

Thanks for watching. 🌟 Please hit on LIKE ❤ Share 🔥 SUBSCRIBE for more AMAZING content on every week! 🌟

CodenboxAutomationLab
Автор

Hi I am getting null pointer exception using the below code with data reader provided by you
package com.pages;

import java.util.ArrayList;

import com.pages.DataReader;

/*
* Please ignore this class for now.
* can be used in order to execute the same test case with multiple data by reading the data from excel sheet and
* storing in Arraylist. This list can be called in methods using @dataProvider annotation
*
*/
public class TestUtil {
static DataReader reader;

public static ArrayList<Object[]> getExcelData() {

ArrayList<Object[]> Data = new ArrayList<Object[]>();

try {
reader = new
} catch (Exception e) {
e.printStackTrace();
}
int totalrows = reader.getRowCount("1");
for (int rowNum = 2; rowNum <= totalrows;rowNum++)
{
String firstname = reader.getCellData("1", "Firstname", rowNum);
String lastName = reader.getCellData("1", "LastName", rowNum);
String email = reader.getCellData("1", "Email", rowNum);
String password = reader.getCellData("1", "Password", rowNum);
String month = reader.getCellData("1", "Month", rowNum);
String day = reader.getCellData("1", "Day", rowNum);
String year = reader.getCellData("1", "Year", rowNum);
String gender = reader.getCellData("1", "Gender", rowNum);
Object Obj[] = {firstname, lastName, email, password, month, day, year, gender};

Data.add(Obj);
}
return Data;
}

/*
* public static Object[][] getTestdata(String string) { // TODO Auto-generated
* method stub return null; }
*/

}



And the error is:-


at Source)
at Source)
at
at
at
at Method)
at Source)
at Source)
at Source)
at
at
at
at
at
at
at
at
at
at
at
at
at Source)
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
[Utils] [ERROR] [Error]
at
at
at
at Method)
at Source)
at Source)
at Source)
at
at
at
at
at
at
at
at
at
at
at
at
at Source)
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at

SKIPPED: signUpPageTest
java.lang.RuntimeException:
at
at
at
at
at
at
at
at
at
at
at Source)
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
Caused by:
at
at
at
at Method)
at Source)
at Source)
at Source)
at
at
at
... 25 more



Default test
Tests run: 1, Failures: 0, Skips: 1




Default suite
Total tests run: 1, Passes: 0, Failures: 0, Skips: 1

kamalverma
welcome to shbcf.ru