Search in sources :

Example 6 with LocatorModel

use of com.driver.locator.model.LocatorModel in project selenium_java by sergueik.

the class PageObjectGenerator method writeToFile.

@Override
public boolean writeToFile(String fileName, List<LocatorModel> dData) {
    count = 1;
    File file = new File(ResourceHelper.getResourcePath("pageobject/") + fileName + ".java");
    if (!file.exists())
        try {
            file.createNewFile();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    try (FileWriter fWrite = new FileWriter(file, false)) {
        fWrite.append("\n").append("public class " + fileName + " {");
        for (LocatorModel model : dData) {
            fWrite.append(getWebElementString(model.getLocatorType(), model.getLocatorValue()));
        }
        fWrite.append("\n").append("}");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
Also used : LocatorModel(com.driver.locator.model.LocatorModel) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Example 7 with LocatorModel

use of com.driver.locator.model.LocatorModel in project selenium_java by sergueik.

the class ExcelFileWriter method writeToFile.

@Override
public boolean writeToFile(String fileName, List<LocatorModel> dData) {
    int i = 0;
    try (XSSFWorkbook book = getWorkBook()) {
        XSSFSheet sheet = book.createSheet(SHEET_NAME);
        for (LocatorModel model : dData) {
            XSSFRow row = sheet.createRow(i++);
            row.createCell(0).setCellValue(model.getLocatorType());
            row.createCell(1).setCellValue(model.getLocatorValue());
        }
        book.write(new FileOutputStream(new File(ResourceHelper.getResourcePath("excel/") + fileName + ".xlsx")));
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) LocatorModel(com.driver.locator.model.LocatorModel) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) FileOutputStream(java.io.FileOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) File(java.io.File) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) IOException(java.io.IOException)

Aggregations

LocatorModel (com.driver.locator.model.LocatorModel)7 ArrayList (java.util.ArrayList)4 IgnoreAttribute (com.driver.locator.model.IgnoreAttribute)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Attribute (org.jsoup.nodes.Attribute)2 NullRemove (com.driver.locator.utility.NullRemove)1 CSVWriter (com.opencsv.CSVWriter)1 FileOutputStream (java.io.FileOutputStream)1 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1 Elements (org.jsoup.select.Elements)1