Posts

Showing posts with the label File Reading Ways

Simple DDT(Data driven testing) | Read user's detail from excel & login to application multiple times

Image
Hello Dear Friends!!! I hope you are doing well!!! So guys in today's article we are going to see below points. 1. Data driven testing using excel 2. Simple ways and methods to read data from excel file 3. Read data from excel and Automate web application 4. Use of @DataProvider annotation in TestNG framework Problem Statement : Read multiple user's credentials from excel file and login to application one by one. In last session we have created one project i.e. TestNGDemo, so  that project only will take for the today's demo. To watch last session open mentioned link :  TestNG Demo And to watch today's session on YouTube open mentioned link :   DDT Session Solution : For the demo will create two classes and using one input file as mentioned below : 1. LoginDemo.java  2. ExcelReadingMethods.java 3. Input file LoginData.xlsx 1.  LoginDemo.java  //This class is for writing the Test Cas...

Simple Java Code To Read Password Protected XLSX File

package com.techhelpline.PractiseCode; import java.io.File; import java.io.InputStream; import java.util.Iterator; import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ReadProtectedFileXLSX { public static void main(String[] args) { String inputFilePath = "UserDetails.xlsx"; String password = "test"; try { NPOIFSFileSystem fileSystem = new NPOIFSFileSystem(new File(inputFilePath)); EncryptionInfo info = new EncryptionInfo(fileSystem); Decryptor decryptor = Decryptor.getInstance(info); if (!decryptor.verifyPassword(password)) { System.out.println("File in password protected."); ...

Simple Java Code To Read Password Protected XLS File

package com.techhelpline.PractiseCode; import java.io.File; import java.io.IOException; import java.util.Iterator; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; public class ReadProtectedFileXLS { public static void main(String[] args) throws IOException { String inputFilePath = "UserDetails.xls"; String password="test"; NPOIFSFileSystem fileSystem = new NPOIFSFileSystem(new File(inputFilePath), true); Biff8EncryptionKey.setCurrentUserPassword(password); Workbook workbook = new HSSFWorkbook(fileSystem); Sheet firstSheet = workbook.getSheetAt(0); Iterator<Row> iterator = firstSheet.iterator(); while (iterator.hasNext()) { ...