DDF 3.x version has only support for TestNG, with the DDF 4.0 version you can use DataDrivenFramework with out using TestNG API.
Current implementation of DataDrivenFramework can be integrated with any automation tool/api which supports java (ex: Java Webdriver, Openscript, etc). It can also be used as part of application development for reading the data from Excel file.
For information on other DDF versions click link DataDrivenFramework.
1. Prerequisite:
i. Java 1.6
ii. Eclipse IDE or any other Java IDE (ex: NetBeans IDE)
iii. Set POI API jar files in java build path.
Download Apache POI, follow below process
1. Goto url: http://poi.apache.org/
2. Click on "download" link (i.e. http://poi.apache.org/download.html page opens)
3. Click on "poi-bin-<<version>>.zip" link
4. Select the mirror and download the "poi-<<version>>.zip"
5. Extract the downloaded "poi-<<version>>.zip" file, next step is to set the java build path.
Files required in java build path.
1. poi-<<version>>.jar
2. poi-ooxml-<<version>>.jar
3. poi-ooxml-schemas-<<version>>.jar
Open the "ooxml-lib" folder present in the extracted "poi-<<version>>.zip" file, set the below jar files in java build path.
4. dom4j-<<version>>.jar
5. xmlbeans-<<version>>.jar
7. Extract the "DDF Version - 4.0.zip" (zip file contains example programs and jar file).
8. Set "AH-DDF-4.0.jar" in java build path.
Note:
'AH-DDF-<<Version>>.jar' is proprietary jar file, distributed for free.
Java Build Path:
Test Data:
Sample Program:
package examples.Non_TestNG_test.xml;
import java.io.File;
import java.util.List;
import java.util.Map;
import automation_home.ddf.constants.XMLConstants;
import automation_home.ddf.wrapper.Wrapper;
import automation_home.ddf.wrapperimpl.XMLWrapper;
public class TestData {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
for(Map<String, String> h : configure()){
System.out.println("FlightName : "+h.get("FlightName"));
System.out.println("FlightNumber : "+h.get("FlightNumber"));
System.out.println("AirPort : "+h.get("AirPort"));
System.out.println("Date : "+h.get("Date"));
System.out.println("----------------------------------------");
}
}
public static List<Map<String, String>> configure() throws Exception{
Wrapper wrapper = new XMLWrapper();
wrapper.setParameter(XMLConstants.FILE_PATH, new File("").getAbsolutePath()+"\\src\\examples\\Non_TestNG_test\\xml\\FlightInfo.xml");
wrapper.setParameter(XMLConstants.NODE_NAME, "flight-details");
wrapper.setParameter(XMLConstants.INCLUDE_TESTDATA_HEADER_NAME, "TestInclude");
wrapper.setParameter(XMLConstants.INCLUDE_TESTDATA_YES,"true");
wrapper.setParameter(XMLConstants.INCLUDE_TESTDATA_NO,"false");
List<Map<String, String>> list = wrapper.retrieveData();
return list;
}
}
Output:
No comments:
Post a Comment