STEP 8
Prerequisite : All the steps from STEP 1 to STEP 7 should live on followed properly every bit described.
We receive got added file reading utility In our selenium webdriver software automation testing information driven framework thus right away nosotros are all ready to read information from the .xls files. As y'all all know, Right right away nosotros receive got 2 exam suites In our software automation testing framework together with each test suite receive got 2 exam cases. So full at that topographic point are 2 exam suites together with 4 exam cases In our software automation testing framework. And also nosotros receive got created 2 dissever .xls files for each exam suite. So .xls files together with their sheets mapping amongst the exam suites together with their exam cases volition live on every bit bellow.
- com.stta.SuiteOne -> SuiteOne.xls
- SuiteOneCaseOne.java -> SuiteOneCaseOne Sheet
- SuiteOneCaseTwo.java -> SuiteOneCaseTwo Sheet
- com.stta.SuiteTwo -> SuiteTwo.xls
- SuiteTwoCaseOne.java -> SuiteTwoCaseOne Sheet
- SuiteTwoCaseTwo.java -> SuiteTwoCaseTwo Sheet
Download Required Files
Now allow nosotros essay to read information from SuiteOneCaseOne test information Sheet of SuiteOne.xls File for SuiteOneCaseOne.java test case. For that, You require to download bellow given iii files.
Now allow nosotros essay to read information from SuiteOneCaseOne test information Sheet of SuiteOne.xls File for SuiteOneCaseOne.java test case. For that, You require to download bellow given iii files.
Now copy-paste inwards a higher house downloaded files ane yesteryear ane every bit described bellow to supplant existing files.
(Note : It should supplant existing file when glue It on package. It should non Insert novel file.)
(Note : It should supplant existing file when glue It on package. It should non Insert novel file.)
- Paste SuiteBase.java File on com.stta.TestSuiteBase Package.
- Paste SuiteOneBase.java File on com.stta.SuiteOne Package.
- Paste SuiteOneCaseOne.java File on com.stta.SuiteOne Package.
SuiteBase.java File Explanation
Open this file In your eclipse together with sentiment the code. I receive got created Init() percentage In this file to Initialize all .xls file's paths.
Note : Your all .xls files must live on located at bellow given path. If .xls files are located at whatsoever other place thus y'all receive got to modify all file's path In SuiteBase.java too.
.xls File's Paths should Be : E:\backup\Training\WDDF\src\com\stta\ExcelFiles
SuiteOneBase.java File Explanation
This file produce non receive got whatsoever percentage on this stage. It Is but child class of SuiteBase. Will Implement required functions later on on.
SuiteOneCaseOne.java File Explanation
This Is our exam example file. Using this file, nosotros volition read exam information from .xls file together with thus print them In console. This file contains bellow given dissimilar functions together with usage of all those functions Is described bellow.
- checkCaseToRun() : If y'all volition await at this function, I receive got used TestNG @BeforeTest notation inwards a higher house the function. That agency It volition live on executed earlier the @Test notation method or nosotros tin say earlier starting of exam execution. It volition call Init() function from SuiteBase class to Initialize .xls files together with thus set SuiteOne.xls file's path In FilePath variable.
- SuiteOneCaseOneTest() : This percentage has TestNG @Test notation that agency It volition live on executed after execution of @BeforeTest annotation function. Also used dataProvider with @Test annotation to convey exam information from SuiteOneCaseOneData() dataprovider function. It will accept iv string declaration values On every Iteration.
- SuiteOneCaseOneData() : It volition recollect exam information from SuiteOne.xls file's SuiteOneCaseOne sail together with render information to SuiteOneCaseOneTest() function.
Note : retrieveTestData(String wsName) percentage In Read_XLS.java file Is written In such a way thus that ever It volition skip reading of final 2 columns of information sheet("DataToRun" together with "Pass/Fail/Skip").
Running Sample .xls Data Reading Test
Now It Is fourth dimension to run our sample information reading exam to brand certain that every affair Is fine.
- Right click on SuiteOneCaseOne.java file In eclipse together with larn to Run As -> TestNG Test every bit shown bellow.
It volition execute your software exam example using TestNG. @Test notation method volition live on executed 2 times because at that topographic point are 2 information rows In SuiteOneCaseOne exam information sheet. On completion of exam execution, You volition run across bellow given number In your console.
Console Result
If y'all tin run across inwards a higher house results thus everything Is fine till right away In your software testing information driven framework creation. We succeed for running sample information reading exam In our webdriver information driven framework.