br.com.jarch.apt.generate.SystemTestGenerate Maven / Gradle / Ivy
package br.com.jarch.apt.generate;
import br.com.jarch.annotation.*;
import br.com.jarch.form.FieldForm;
import br.com.jarch.model.type.ActionCrudType;
import br.com.jarch.util.FileUtils;
import br.com.jarch.util.LogUtils;
import br.com.jarch.util.ProcessorUtils;
import br.com.jarch.util.type.FieldType;
import javax.lang.model.element.Element;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static br.com.jarch.util.ProcessorUtils.addCode;
import static br.com.jarch.util.ProcessorUtils.addLineBlank;
public final class SystemTestGenerate {
private File fileTest;
private File filePage;
private String namePackage;
private String nome;
private String nomeSemCaracterEspecial;
private String nomeSemCaracterEspecialMinusculo;
private List listFieldFormMaster;
private Element element;
private JArchGenerateLogicCrud generateLogicCrud;
private JArchGenerateLogicMasterDetail generateLogicMasterDetail;
private JArchGenerateLogicMasterSubDetail generateLogicMasterSubDetail;
public SystemTestGenerate(Element element, JArchGenerateLogicCrud generateLogicCrud) {
this.generateLogicCrud = generateLogicCrud;
this.element = element;
this.listFieldFormMaster = ProcessorUtils.getListFieldForm(generateLogicCrud.master().fields());
configure(element, generateLogicCrud.master().name(), generateLogicCrud.nameSubPackage());
}
public SystemTestGenerate(Element element, JArchGenerateLogicMasterDetail generateLogicMasterDetail) {
this.generateLogicMasterDetail = generateLogicMasterDetail;
this.element = element;
this.listFieldFormMaster = ProcessorUtils.getListFieldForm(this.generateLogicMasterDetail.master().fields());
configure(element, generateLogicMasterDetail.master().name(), generateLogicMasterDetail.nameSubPackage());
}
public SystemTestGenerate(Element element, JArchGenerateLogicMasterSubDetail generateLogicMasterSubDetail) {
this.generateLogicMasterSubDetail = generateLogicMasterSubDetail;
this.element = element;
this.listFieldFormMaster = ProcessorUtils.getListFieldForm(generateLogicMasterSubDetail.master().fields());
configure(element, generateLogicMasterSubDetail.master().name(), generateLogicMasterSubDetail.nameSubPackage());
}
public void create() {
saveTest();
savePage();
}
private void saveTest() {
if (fileTest.exists()) {
return;
}
StringBuilder sbSystemTest = new StringBuilder();
addCode(sbSystemTest, "package " + namePackage + ";");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "import br.com.jarch.test.BrowseFactory;");
addCode(sbSystemTest, "import br.com.jarch.test.TestUtils;");
addCode(sbSystemTest, "import br.com.jarch.test.system.CrudSystemTest;");
addCode(sbSystemTest, "import org.junit.AfterClass;");
addCode(sbSystemTest, "import org.junit.BeforeClass;");
addCode(sbSystemTest, "import org.openqa.selenium.WebDriver;");
addCode(sbSystemTest, "import org.openqa.selenium.support.PageFactory;");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "public class " + nomeSemCaracterEspecial + "SystemTest extends CrudSystemTest<" + nomeSemCaracterEspecial + "Page> {");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "\tprivate static WebDriver driver;");
addCode(sbSystemTest, "\tprivate static " + nomeSemCaracterEspecial + "Page " + nomeSemCaracterEspecialMinusculo + "Page;");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "\tstatic {");
addCode(sbSystemTest, "\t\tdriver = BrowseFactory.getChromeDriver();");
addCode(sbSystemTest, "\t\t" + nomeSemCaracterEspecialMinusculo + "Page = PageFactory.initElements(driver, " + nomeSemCaracterEspecial + "Page.class);");
addCode(sbSystemTest, "\t}");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "\t@Override");
addCode(sbSystemTest, "\tpublic " + nomeSemCaracterEspecial + "Page getPage() {");
addCode(sbSystemTest, "\t\treturn " + nomeSemCaracterEspecialMinusculo + "Page;");
addCode(sbSystemTest, "\t}");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "\t@BeforeClass");
addCode(sbSystemTest, "\tpublic static void beforeClass() {");
addCode(sbSystemTest, "\t\tTestUtils.login(driver, \"" + getUrlApplication() + "/paginas/login/login.jsf?multiTenantId=1&systemTest=S\", \"login\", \"senha\");");
addCode(sbSystemTest, "\t}");
addLineBlank(sbSystemTest);
addCode(sbSystemTest, "\t@AfterClass");
addCode(sbSystemTest, "\tpublic static void afterClass() {");
addCode(sbSystemTest, "\t\tTestUtils.logout(driver);");
addCode(sbSystemTest, "\t}");
addCode(sbSystemTest, "}");
try {
FileUtils.save(fileTest, sbSystemTest.toString());
ProcessorUtils.messageNote("JARCH Created ==> " + fileTest.getAbsoluteFile(), element);
} catch (IOException e) {
LogUtils.generate(e);
}
}
private void savePage() {
if (filePage.exists()) {
return;
}
StringBuilder sbPage = new StringBuilder();
addCode(sbPage, "package " + namePackage + ";");
addLineBlank(sbPage);
addImportsPage(sbPage);
addLineBlank(sbPage);
addCode(sbPage, "public class " + nomeSemCaracterEspecial + "Page extends CrudPage {");
addLineBlank(sbPage);
addMethodConstruct(sbPage);
addInjectWebComponentFilter(sbPage);
addInjectWebComponentData(sbPage);
addInjectWebComponentTabDetail(sbPage);
addInjectWebComponentTabSubDetail(sbPage);
addMethodGetFolderXhtml(sbPage);
addMethodGetPageList(sbPage);
addMethodGetPageData(sbPage);
addMethodActionInsert(sbPage);
addMethodActionClone(sbPage);
addMethodActionChange(sbPage);
addMethodActionConsult(sbPage);
addMethodActionDelete(sbPage);
addCode(sbPage, "}");
try {
FileUtils.save(filePage, sbPage.toString());
ProcessorUtils.messageNote("Create Page Class ==> " + filePage.getAbsoluteFile(), element);
} catch (IOException e) {
LogUtils.generate(e);
}
}
private void addMethodConstruct(StringBuilder sbPage) {
addCode(sbPage, "\tpublic " + nomeSemCaracterEspecial + "Page(WebDriver driver) {");
addCode(sbPage, "\t\tsuper(driver);");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodActionDelete(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tpublic void actionDelete() {");
addCode(sbPage, "\t\tgoDeleteDataInsertAndDataChange(" + getWebElementFilterString() + ", FieldType." + getWebElementFilterFieldForm().getTipo().name() + (generateLogicCrud == null ? "" : ", true") + ");");
addCode(sbPage, "\t}");
}
private void addMethodActionConsult(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tpublic void actionConsult() {");
addCodeGoPageListFilterChange(sbPage);
addCode(sbPage, "\t\tclickListActionConsult();");
addCode(sbPage, "\t\twaitForPageData();");
if (generateLogicCrud != null) {
addCode(sbPage, "\t\tscrollBottomPage();");
}
addCode(sbPage, "\t\tclickMasterReturn();");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodActionChange(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tpublic void actionChange() {");
addCodeGoPageListFilterClone(sbPage);
addCode(sbPage, "\t\tclickListActionChange();");
addClickClearSendkeysChange(sbPage);
if (generateLogicCrud != null) {
addCode(sbPage, "\t\tscrollBottomPage();");
}
addCode(sbPage, "\t\tclickMasterSave();");
addCode(sbPage, "\t\twaitForMessageSuccess();");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodActionClone(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tpublic void actionClone() {");
addCodeGoPageListFilterInsert(sbPage);
addCode(sbPage, "\t\tclickListActionClone();");
addClickClearSendkeysClone(sbPage);
if (generateLogicCrud != null) {
addCode(sbPage, "\t\tscrollBottomPage();");
}
addCode(sbPage, "\t\tclickMasterSave();");
addCode(sbPage, "\t\twaitForMessageSuccess();");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodActionInsert(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tpublic void actionInsert() {");
addCode(sbPage, "\t\tgoPageListFromUrl();");
addCode(sbPage, "\t\tclickListActionInsert();");
addClickClearSendkeysInsert(sbPage);
if (generateLogicCrud != null) {
addCode(sbPage, "\t\tscrollBottomPage();");
}
addCode(sbPage, "\t\tclickMasterSave();");
addCode(sbPage, "\t\twaitForMessageSuccess();");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodGetPageData(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tprotected String getPageData() {");
addCode(sbPage, "\t\treturn \"" + nomeSemCaracterEspecialMinusculo + "Data.jsf\";");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodGetFolderXhtml(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tprotected String getFolderXhtml() {");
addCode(sbPage, "\t\treturn \"" + nomeSemCaracterEspecialMinusculo.toLowerCase() + "\";");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addMethodGetPageList(StringBuilder sbPage) {
addCode(sbPage, "\t@Override");
addCode(sbPage, "\tprotected String getPageList() {");
addCode(sbPage, "\t\treturn \"" + nomeSemCaracterEspecialMinusculo + "List.jsf\";");
addCode(sbPage, "\t}");
addLineBlank(sbPage);
}
private void addImportsPage(StringBuilder sbPage) {
addCode(sbPage, "import br.com.jarch.test.page.CrudPage;");
addCode(sbPage, "import br.com.jarch.util.type.FieldType;");
addCode(sbPage, "import org.openqa.selenium.WebDriver;");
addCode(sbPage, "import org.openqa.selenium.WebElement;");
addCode(sbPage, "import org.openqa.selenium.support.FindBy;");
addCode(sbPage, "import org.openqa.selenium.support.How;");
listFieldFormMaster
.stream()
.filter(f -> f.getTipo().isEnum())
.forEach(f -> addCode(sbPage, "import " + namePackage.replace("test", "client").concat(".").concat(f.getAtributoPrimeiroLetraMaiusculo().concat("Type;"))));
}
private void addCodeGoPageListFilterInsert(StringBuilder sbPage) {
FieldForm fieldForm = getWebElementFilterFieldForm();
addCode(sbPage, "\t\tgoPageListAndFilter(" + getWebElementFilterString() + ", FieldType." + fieldForm.getTipo().name() + ".getValueInsertTest());");
}
private void addCodeGoPageListFilterClone(StringBuilder sbPage) {
FieldForm fieldForm = getWebElementFilterFieldForm();
addCode(sbPage, "\t\tgoPageListAndFilter(" + getWebElementFilterString() + ", FieldType." + fieldForm.getTipo().name() + ".getValueCloneTest());");
}
private void addCodeGoPageListFilterChange(StringBuilder sbPage) {
FieldForm fieldForm = getWebElementFilterFieldForm();
addCode(sbPage, "\t\tgoPageListAndFilter(" + getWebElementFilterString() + ", FieldType." + fieldForm.getTipo().name() + ".getValueChangeTest());");
}
private FieldForm getWebElementFilterFieldForm() {
return listFieldFormMaster
.stream()
.filter(f -> !f.getSearch().isEmpty())
.findFirst()
.get();
}
private String getWebElementFilterString() {
return "webElement" + nomeSemCaracterEspecial + getWebElementFilterFieldForm().getAtributoPrimeiroLetraMaiusculo() + "FilterSearch";
}
private void addInjectWebComponentFilter(StringBuilder sbSystemTest) {
listFieldFormMaster
.stream()
.filter(f -> !f.getSearch().isEmpty())
.forEach(fieldForm -> {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//input[contains(@id, 'filterSearch" + fieldForm.getAtributo() + "')]\")");
addCode(sbSystemTest, "\tprivate WebElement webElement" + nomeSemCaracterEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + "FilterSearch;");
addLineBlank(sbSystemTest);
}
);
}
private void addInjectWebComponentDataListFormField(StringBuilder sbSystemTest, String name, String dataDetail, List fieldForms) {
fieldForms
.stream()
.filter(f -> f.isObrigatorio())
.forEach(fieldForm -> {
if (fieldForm.getTipo().isEnum() || fieldForm.getTipo().equals(FieldType.BOOLEAN)) {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//div[contains(@id, '" + fieldForm.getGenerateId(name, dataDetail) + "')]\")");
addCode(sbSystemTest, "\tprivate WebElement webElement" + fieldForm.getGenerateId(name, dataDetail).substring(2) + ";");
addLineBlank(sbSystemTest);
} else {
if (fieldForm.getTipo().equals(FieldType.ADDRESS)) {
addCode(sbSystemTest, "\t@FindBy(how = How.CSS, css = \"div[id *= '" + fieldForm.getGenerateId(name, dataDetail) + "'] input[id *= 'zipCode']\")");
} else if (fieldForm.getTipo().equals(FieldType.MEMO_RICH)) {
addCode(sbSystemTest, "\t@FindBy(how = How.CSS, css = \"div[id *= '" + fieldForm.getGenerateId(name, dataDetail) + "'] .ql-editor\")");
} else {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//input[contains(@id, '" + fieldForm.getGenerateId(name, dataDetail) + (fieldForm.getTipo().isAddress() ? ":zipCode" : "") + "')]\")");
}
addCode(sbSystemTest, "\tprivate WebElement webElement" + fieldForm.getGenerateId(name, dataDetail).substring(2) + ";");
addLineBlank(sbSystemTest);
}
}
);
}
private void addInjectWebComponentTabDetail(StringBuilder sbSystemTest) {
if (generateLogicMasterDetail != null) {
Arrays
.stream(generateLogicMasterDetail.details())
.forEach(detail -> {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//a[contains(@href, 'tab" + ProcessorUtils.getNameWithoutCharEspecialCapitalize(detail.name()) + "')]/span/input\")");
addCode(sbSystemTest, "\tprivate WebElement webElementInsert" + ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name()) + ";");
addLineBlank(sbSystemTest);
});
}
}
private void addInjectWebComponentTabSubDetail(StringBuilder sbSystemTest) {
if (generateLogicMasterSubDetail != null) {
Arrays
.stream(generateLogicMasterSubDetail.details())
.forEach(detail -> {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//a[contains(@href, 'tab" + ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name()) + "')]/span/input\")");
addCode(sbSystemTest, "\tprivate WebElement webElementInsert" + ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name()) + ";");
addLineBlank(sbSystemTest);
});
Arrays
.stream(generateLogicMasterSubDetail.details())
.forEach(detail -> Arrays
.stream(detail.subDetails())
.forEach(subDetail -> {
addCode(sbSystemTest, "\t@FindBy(how = How.XPATH, xpath = \"//a[contains(@href, 'tab" + ProcessorUtils.getNameWithoutCharEspecialCapitalize(subDetail.name()) + "')]/input\")");
addCode(sbSystemTest, "\tprivate WebElement webElementInsert" + ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(subDetail.name()) + ";");
addLineBlank(sbSystemTest);
}));
}
}
private void addInjectWebComponentData(StringBuilder sbSystemTest) {
addInjectWebComponentDataListFormField(sbSystemTest, nomeSemCaracterEspecial, "", listFieldFormMaster);
if (generateLogicMasterDetail != null) {
Arrays
.stream(generateLogicMasterDetail.details())
.forEach(detail -> addInjectWebComponentDataListFormField(sbSystemTest, nomeSemCaracterEspecial, ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name()), ProcessorUtils.getListFieldForm(detail.fields())));
}
if (generateLogicMasterSubDetail != null) {
Arrays
.stream(generateLogicMasterSubDetail.details())
.forEach(detail -> addInjectWebComponentDataListFormField(sbSystemTest, nomeSemCaracterEspecial, ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name()), ProcessorUtils.getListFieldForm(detail.fields())));
Arrays
.stream(generateLogicMasterSubDetail.details())
.forEach(detail -> Arrays
.stream(detail.subDetails())
.forEach(subDetail -> addInjectWebComponentDataListFormField(sbSystemTest, nomeSemCaracterEspecial, ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(subDetail.name()), ProcessorUtils.getListFieldForm(subDetail.fields()))));
}
}
private void addClickClearSendkeysInsert(StringBuilder sbSystemTest) {
listFieldFormMaster
.forEach(fieldForm -> addCodeFillWebComponentInsert(sbSystemTest, nome, fieldForm));
if (generateLogicMasterDetail != null) {
for (JArchGenerateDetail detail : Arrays.stream(generateLogicMasterDetail.details()).collect(Collectors.toList())) {
String nomeSemCaracterEspecialDetailStartLowerCase = ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name());
String nomeSemCaracterEspecialDetailCapitalize = ProcessorUtils.getNameWithoutCharEspecialCapitalize(detail.name());
addCode(sbSystemTest, "\t\tscrollTo(webElementInsert" + nomeSemCaracterEspecialDetailStartLowerCase + ");");
addCode(sbSystemTest, "\t\tclickDetailActionInsert(\"tab" + nomeSemCaracterEspecialDetailCapitalize + "\");");
ProcessorUtils
.getListFieldForm(detail.fields())
.forEach(fieldForm -> addCodeFillWebComponentInsert(sbSystemTest, nomeSemCaracterEspecialDetailStartLowerCase, fieldForm));
addCode(sbSystemTest, "\t\tclickDetailSave();");
}
}
if (generateLogicMasterSubDetail != null) {
for (JArchGenerateDetailSubDetail detail : Arrays.stream(generateLogicMasterSubDetail.details()).collect(Collectors.toList())) {
String nomeSemCaracterEspecialDetailStartLowerCase = ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(detail.name());
String nomeSemCaracterEspecialDetailCapitalize = ProcessorUtils.getNameWithoutCharEspecialCapitalize(detail.name());
addCode(sbSystemTest, "\t\tscrollTo(webElementInsert" + nomeSemCaracterEspecialDetailStartLowerCase + ");");
addCode(sbSystemTest, "\t\tclickDetailActionInsert(\"tab" + nomeSemCaracterEspecialDetailCapitalize + "\");");
ProcessorUtils
.getListFieldForm(detail.fields())
.forEach(fieldForm -> addCodeFillWebComponentInsert(sbSystemTest, nomeSemCaracterEspecialDetailStartLowerCase, fieldForm));
for (JArchGenerateSubDetail subDetail : Arrays.stream(detail.subDetails()).collect(Collectors.toList())) {
String nomeSemCaracterEspecialSubDetailStartLowerCase = ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(subDetail.name());
String nomeSemCaracterEspecialSubDetailCapitalize = ProcessorUtils.getNameWithoutCharEspecialCapitalize(subDetail.name());
addCode(sbSystemTest, "\t\tscrollTo(webElementInsert" + nomeSemCaracterEspecialSubDetailStartLowerCase + ");");
addCode(sbSystemTest, "\t\tclickDetailActionInsert(\"tab" + nomeSemCaracterEspecialSubDetailCapitalize + "\");");
ProcessorUtils
.getListFieldForm(subDetail.fields())
.forEach(fieldForm -> addCodeFillWebComponentInsert(sbSystemTest, nomeSemCaracterEspecialSubDetailStartLowerCase, fieldForm));
addCode(sbSystemTest, "\t\tclickDetailSave();");
}
addCode(sbSystemTest, "\t\tclickDetailSave();");
}
}
}
private void addClickClearSendkeysClone(StringBuilder sbSystemTest) {
listFieldFormMaster
.forEach(fieldForm -> addCodeFillWebComponentClone(sbSystemTest, nome, fieldForm));
}
private void addClickClearSendkeysChange(StringBuilder sbSystemTest) {
listFieldFormMaster
.forEach(fieldForm -> addCodeFillWebComponentChange(sbSystemTest, nome, fieldForm));
}
private void configure(Element element, String name, String nameSubPackage) {
nome = name;
nomeSemCaracterEspecial = ProcessorUtils.getNameWithoutCharEspecialCapitalize(name);
nomeSemCaracterEspecialMinusculo = ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(name);
File folder = new File(ProcessorUtils.getPathTest(element, nameSubPackage).replace("-client", "-web").replace(File.separator + "client" + File.separator, File.separator + "test" + File.separator));
if (!folder.exists()) {
folder.mkdirs();
}
fileTest = new File(folder.getAbsolutePath() + File.separator + nomeSemCaracterEspecial + "SystemTest.java");
filePage = new File(folder.getAbsolutePath() + File.separator + nomeSemCaracterEspecial + "Page.java");
namePackage = ProcessorUtils.getPackage(element, nameSubPackage).replace(".client.", ".test.");
}
private String getUrlApplication() {
String context = filePage.getAbsolutePath();
if (context.contains("-web")) {
context = context.substring(0, context.indexOf("-web"));
} else if (context.contains("-client")) {
context = context.substring(0, context.indexOf("-client"));
} else {
context = "";
}
if (!context.isEmpty()) {
context = context.substring(context.lastIndexOf(File.separator) + 1);
}
if (context.isEmpty()) {
context = "myapp";
}
context = context.replace("\\", "/");
return "http://localhost:8080/" + context;
}
private void addCodeFillWebComponentInsert(StringBuilder sbSystemTest, String name, FieldForm fieldForm) {
addCodeFillWebComponent(sbSystemTest, name, fieldForm, ActionCrudType.INSERT);
}
private void addCodeFillWebComponentClone(StringBuilder sbSystemTest, String name, FieldForm fieldForm) {
addCodeFillWebComponent(sbSystemTest, name, fieldForm, ActionCrudType.CLONE);
}
private void addCodeFillWebComponentChange(StringBuilder sbSystemTest, String name, FieldForm fieldForm) {
addCodeFillWebComponent(sbSystemTest, name, fieldForm, ActionCrudType.CHANGE);
}
private void addCodeFillWebComponent(StringBuilder sbSystemTest, String name, FieldForm fieldForm, ActionCrudType actionCrudType) {
if (!fieldForm.isObrigatorio()) {
return;
}
String nameNoCharEspecial = ProcessorUtils.getNameWithoutCharEspecialCapitalize(name);
String action = actionCrudType.name().substring(0, 1).concat(actionCrudType.name().substring(1).toLowerCase());
// if (fieldForm.getColumnDataXhtml() == 1) {
// addCode(sbSystemTest, "\t\tscrollTo(webElement" + nameNoCharEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + ");");
// }
if (fieldForm.getTipo().isEnum()) {
// addCode(sbSystemTest, "\t\tclickSelect(\"" + fieldForm.getGenerateId(name, dataDetail) + "\", " + ((actionCrudType.ordinal() % 2) + 2) + ");");
addCode(sbSystemTest, "\t\tclickSelect(webElement" + nameNoCharEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + ", " + fieldForm.getAtributoPrimeiroLetraMaiusculo() + "Type.SAMPLE" + (actionCrudType.isInsert() || actionCrudType.isChange() ? "1" : "2") + ".name());");
} else if (fieldForm.getTipo().equals(FieldType.BOOLEAN)) {
addCode(sbSystemTest, "\t\tclick(webElement" + nameNoCharEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + ");");
} else if (FieldType.BINARY.equals(fieldForm.getTipo())) {
addCode(sbSystemTest, "\t\tfileUploadPdfFake(webElement" + nameNoCharEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + ");");
} else {
addCode(sbSystemTest, "\t\tclickClearSendKeys(webElement" + nameNoCharEspecial + fieldForm.getAtributoPrimeiroLetraMaiusculo() + ", FieldType." + fieldForm.getTipo().name() + ".getValue" + action + "Test());");
}
if (fieldForm.getTipo() == FieldType.ADDRESS) {
addCode(sbSystemTest, "\t\twaitForAjaxProcess();");
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy