![]() ![]() Public void GmailLoginPage() throws InterruptedException ] * Description : To Perform login operation in Gmail Load the Excel Sheet Col in to Dictionary for Further use in our Test void Author : Karthik KK XlsUtil = new ExcelSheetDriver("D:\\Data.xls") Let's assume we have only one Excel File which holds all Testcases. Public ReadDataTest() throws BiffException, IOException Constructor to initialze Excel for Data source WebDriver driver = new InternetExplorerDriver() * Description: To perform Gmail Login using Data driven approach Perform User Name and password entry with different combinations of value by reading from Excel sheet Step 2: Create a TestNG Class file to perform Gmail LoginĢ. Next we are going to create actual test file which is going to perform intended operation, here we are going to perform Gmail login functionality. Value = ((Integer) dict.get(colName)).intValue() ![]() Public static int GetCell(String colName) Iterate through all the columns in the Excel sheet and store the value in Hashtableįor(int col=0 col < wrksheet.getColumns() col ) Create Column Dictionary to hold all the Column Names Return wrksheet.getCell(column,row).getContents() Public static String ReadCell(int column,int row) Returns the Cell value by taking row and Column values as argument For Demo purpose the excel sheet path is hardcoded, but not recommended :) Wrkbook = Workbook.getWorkbook(new File(ExcelSheetPath)) Public ExcelSheetDriver(String ExcelSheetPath) throws BiffException, IOException * Description: Reusable Library file to perform Excel related operations * Date : Create a function to read from the Dictionary Create a Dictionary to store Excel Sheet Column nameĥ. Read Cell value from a specified locationĤ. Step 1 : Create a library file with all the below mentioned functionalityģ. The library file need to have following basic functionality in hand, let say In order to perform data driven testing, all we need to do is create a reusable library file just for Excel using JXL. Well, for this I don’t want to bore you guys with lot of theoretical contents which you can always find some way or other, but I would like to show the real working code. How can I use this in my Selenium framework which I have? What are the steps which has to be taken care to make my framework a data driven framework? But the greatest question of the day is, how to use JXL for data driven testing ?. We have learned what is Data driven testing and how we can use JXL to read data from Excel Sheets in Part 1 of our previous post. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |