use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class DataEntrySteps method I_enter_repeating_subform_values.
@And("^I enter \"([^\"]*)\" repeating subform values:$")
public void I_enter_repeating_subform_values(String repeatingSubformName, DataTable subformValues) throws Throwable {
BsModal modal = currentOpenedForm();
DataTableRow header = subformValues.getGherkinRows().get(0);
addRepetitiveFormsIfNeeded(repeatingSubformName, modal, subformValues.getGherkinRows().size() - 2);
for (int i = 2; i < subformValues.getGherkinRows().size(); i++) {
DataTableRow row = subformValues.getGherkinRows().get(i);
for (int j = 0; j < header.getCells().size(); j++) {
String label = driver.getAliasTable().getAlias(header.getCells().get(j));
String value = row.getCells().get(j);
LOGGER.finest("entering repeating subform values: label: " + label + ", value:" + value);
modal.form().findFieldsByLabel(label).get(i - 2).fill(value);
Sleep.sleepMillis(100);
}
}
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class DataEntrySteps method subsetColumns.
private static DataTable subsetColumns(DataTable table, List<String> expectedColumns) {
List<String> columns = table.getGherkinRows().get(0).getCells();
List<Integer> columnIndexes = new ArrayList<>();
List<String> missingColumns = new ArrayList<>();
for (String expectedColumn : expectedColumns) {
int index = columns.indexOf(expectedColumn);
if (index == -1) {
missingColumns.add(expectedColumn);
} else {
columnIndexes.add(index);
}
}
if (!missingColumns.isEmpty()) {
throw new AssertionError("Missing expected columns " + missingColumns + " in table:\n" + table.toString());
}
List<List<String>> rows = new ArrayList<>();
for (DataTableRow dataTableRow : table.getGherkinRows()) {
List<String> row = new ArrayList<>();
for (Integer columnIndex : columnIndexes) {
row.add(dataTableRow.getCells().get(columnIndex));
}
rows.add(row);
}
return DataTable.create(rows);
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class DataEntrySteps method I_enter_subform_values.
@And("^I enter \"([^\"]*)\" subform values:$")
public void I_enter_subform_values(String subformName, DataTable subformValues) throws Throwable {
BsModal modal = currentOpenedForm();
DataTableRow header = subformValues.getGherkinRows().get(0);
SubformContainer subform = modal.subform(subformName);
for (int i = 2; i < subformValues.getGherkinRows().size(); i++) {
DataTableRow row = subformValues.getGherkinRows().get(i);
String keyLabel = row.getCells().get(0);
subform.selectKey(keyLabel);
for (int j = 1; j < header.getCells().size(); j++) {
String label = driver.getAliasTable().getAlias(header.getCells().get(j));
modal.form().findFieldByLabel(label).fill(row.getCells().get(j));
}
}
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class DesignSteps method choose_reference_for_field.
@And("^choose reference for field \"([^\"]*)\"$")
public void choose_reference_for_field(String fieldLabel, DataTable dataTable) throws Throwable {
FormDesignerPage page = (FormDesignerPage) driver.getCurrentPage();
page.selectFieldByLabel(driver.alias(fieldLabel));
PropertiesPanel fieldProperties = page.fieldProperties();
for (int i = 0; i < dataTable.getGherkinRows().size(); i++) {
DataTableRow row = dataTable.getGherkinRows().get(i);
fieldProperties.chooseFormDialog().set(row.getCells(), driver.getAliasTable());
}
page.save();
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class DesignSteps method drop_field_in.
// accepts table :
// | label | type | container |
// | MySection | Section | root |
// | MyText | Text | MySection |
@And("^drop field in:$")
public void drop_field_in(DataTable dataTable) throws Throwable {
FormDesignerPage page = (FormDesignerPage) driver.getCurrentPage();
for (int i = 1; i < dataTable.getGherkinRows().size(); i++) {
DataTableRow row = dataTable.getGherkinRows().get(i);
List<String> cells = row.getCells();
String label = cells.get(0);
String fieldType = cells.get(1);
String containerLabel = cells.get(2);
try {
DropLabel dropLabel = page.fields().dropLabel(fieldType);
DropPanel dropPanel = page.dropPanel(containerLabel);
dropPanel.dragAndDrop(dropLabel);
Sleep.sleepMillis(100);
if ("root".equalsIgnoreCase(containerLabel) && (fieldType.equalsIgnoreCase("Section") || fieldType.contains("Sub-Form"))) {
DropPanel containerDropPanel = page.dropPanel(fieldType);
containerDropPanel.getContainer().clickWhenReady();
page.containerProperties().setLabel(label);
} else {
page.selectFieldByLabel(fieldType);
page.fieldProperties().setLabel(driver.getAliasTable().createAlias(label));
}
} catch (Exception e) {
throw new RuntimeException("Failed to add field '" + label + "' in form designer UI", e);
}
}
page.save();
}
Aggregations