This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Dependencies: | |
import org.apache.log4j.Logger; | |
import org.apache.log4j.xml.DOMConfigurator; | |
--> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> | |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> | |
<appender name="fileAppender" class="org.apache.log4j.FileAppender"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method takes a HSSFCell value (a field in Excel file) and returns the value in String format | |
private static String cellToString(HSSFCell cell) { | |
int type = cell.getCellType(); | |
Object result; | |
switch (type) { | |
case HSSFCell.CELL_TYPE_NUMERIC: //0 | |
result = cell.getNumericCellValue(); | |
break; | |
case HSSFCell.CELL_TYPE_STRING: //1 | |
result = cell.getStringCellValue(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies: POI | HSSF Workbook/Sheet/Row/Cell | |
// This method will read and return Excel data into a double array | |
public static String[][] get(String filename) { | |
String[][] dataTable = null; | |
File file = new File(filename); | |
try { | |
// Create a file input stream to read Excel workbook and worksheet | |
FileInputStream xlfile = new FileInputStream(file); | |
HSSFWorkbook xlwb = new HSSFWorkbook(xlfile); | |
HSSFSheet xlSheet = xlwb.getSheetAt(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method will read a CSV file and return a List of String[] | |
public static List<String[]> get(String filename) { | |
List<String[]> data = new ArrayList<String[]>(); | |
String testRow; | |
try { | |
// Open and read the file | |
BufferedReader br = new BufferedReader(new FileReader(filename)); | |
// Read data as long as it's not empty | |
// Parse the data by comma using .split() method | |
// Place into a temporary array, then add to List |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies: sqljdbc4 JAR | |
// This method will connect to a SQL Server M.S. database and return a double array | |
public static String[][] get(String query) { | |
int numRows; | |
int numCols = 4; | |
String dataTable[][] = null; | |
// Define connection string | |
String connectionString; | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method takes a screenshot of the browser and saves as a file | |
public static void snap(WebDriver driver, String filename) { | |
String rootFolder = "C:/Users/SeleniumProjects/TestOutput/"; | |
File ScreenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Create file from the screenshot of driver | |
try { | |
FileUtils.copyFile(ScreenshotFile, new File (rootFolder + filename + ".jpg")); | |
} catch (IOException e) { | |
System.out.println("Could not save the file"); | |
e.printStackTrace(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ADD PROJECT DEPENDENCIES --> | |
<dependencies> | |
<dependency> | |
<groupId>org.testng</groupId> | |
<artifactId>testng</artifactId> | |
<version>6.10</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-java</artifactId> | |
<version>1.2.0</version> | |
</dependency> | |
<dependency> | |
<groupId>info.cukes</groupId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This class returns a WebDriver object using 3 overloaded .get() methods: | |
* 1. get() - default | |
* 2. get(String browserType) | |
* 3. get(String browserType, String webURL) | |
*/ | |
public class DriverFactory { | |
string rootFolder = "C:\\Selenium\\Software\\"; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies: javax.xml.xpath | org.w3c | org.xml | |
public static void setFramework(String file) { | |
// 1. Prepare Xpath | |
XPathFactory xpf = XPathFactory.newInstance(); | |
XPath xPath = xpf.newXPath(); | |
try { | |
// 2. Create XML File | |
InputSource inputSource = new InputSource(file); |
OlderNewer