diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java index 17bfde85..927349f9 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java @@ -137,8 +137,8 @@ public void configureWith(ComponentConfiguration config) { /** * Method used to access DialogField for further configuration. * - * @param label Label of element to access - * @param tab Name of a tab that element is placed on + * @param label Label of element to access + * @param tab Name of a tab that element is placed on * @param fieldType Type of field we would like to access * @return DialogField with our field */ @@ -153,9 +153,9 @@ public DialogField getFieldOnTab(String label, String tab, String fieldType) { /** * Method used to configure a field on a dialog. * - * @param label Label of field to configure + * @param label Label of field to configure * @param fieldType Type of field to configure - * @param value Value that field will be filled with + * @param value Value that field will be filled with * @return ConfigDialog this instance */ @Override @@ -167,7 +167,7 @@ public ConfigDialog setField(String label, String fieldType, Object value) { /** * Method can be used to access a field on currently opened tab * - * @param label Field's label to access + * @param label Field's label to access * @param fieldType Type of field to access * @return DialogField with our field */ @@ -204,9 +204,14 @@ private void configure(ComponentConfiguration config) { private void setFields(List value) { WebElement parent = determineParentScope(); - value.forEach(fieldConfig -> dialogConfigurer - .getDialogField(parent, fieldConfig.getLabel(), fieldConfig.getType()) - .setValue(fieldConfig.getValue())); + value.forEach(fieldConfig -> { + DialogField field = dialogConfigurer + .getDialogField(parent, fieldConfig.getLabel(), fieldConfig.getType()); + if (fieldConfig.getClear()) { + field.clearField(); + } + field.setValue(fieldConfig.getValue()); + }); } private WebElement determineParentScope() { diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Checkbox.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Checkbox.java index 9ec15c71..97bfc845 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Checkbox.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Checkbox.java @@ -20,6 +20,7 @@ package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; import com.cognifide.qa.bb.qualifier.PageObject; + import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -40,15 +41,14 @@ public void select() { } /** - * Performs click action on the checkbox if passed param is 'true' string. + * Sets the checkbox's state with a click according to the passed boolean value. * * @param value string boolean representation */ @Override public void setValue(Object value) { - if (Boolean.valueOf(String.valueOf(value))) { + if (Boolean.valueOf(String.valueOf(value)) != checkboxElement.isSelected()) { select(); } } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Image.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Image.java index d9c3a55d..a26ff6cd 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Image.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Image.java @@ -29,6 +29,7 @@ import com.cognifide.qa.bb.qualifier.PageObject; import com.cognifide.qa.bb.scope.frame.FramePath; import com.google.inject.Inject; + import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -60,5 +61,4 @@ public void setValue(Object value) { Droppable droppable = dragAndDropFactory.createDroppable(dropArea, FramePath.parsePath("/")); draggable.dropTo(droppable); } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Multifield.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Multifield.java index a8406ca3..c7c89da9 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Multifield.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Multifield.java @@ -56,14 +56,19 @@ public void setValue(Object value) { mapper.convertValue(value, new TypeReference>() { }); - items.forEach(MultifieldItem::deleteItem); - - cfg.forEach(entry -> addField()); + while(items.size() < cfg.size()) { + addField(); + } Iterator itemsIterator = items.iterator(); cfg.forEach(entry -> itemsIterator.next().setValue(entry)); } + @Override + public void clearField() { + items.forEach(MultifieldItem::deleteItem); + } + /** * Returns MultifieldItem at declared index position * diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/PathBrowser.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/PathBrowser.java index e017c54d..d7583257 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/PathBrowser.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/PathBrowser.java @@ -68,5 +68,4 @@ public void setValue(Object value) { By.cssSelector(".foundation-picker-buttonlist.coral3-Overlay.is-open"))); currentScope.findElement(By.className("coral-Form-fieldlabel")).click(); } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RadioGroup.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RadioGroup.java index 7593619a..b24d6872 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RadioGroup.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RadioGroup.java @@ -43,5 +43,4 @@ public void setValue(Object value) { () -> new IllegalStateException("Provided option is not present in the group")); radioLabel.findElement(By.xpath(".//..")).click(); } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RichText.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RichText.java index 76b07410..aa5265b4 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RichText.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/RichText.java @@ -25,8 +25,10 @@ import com.cognifide.qa.bb.qualifier.PageObject; import com.google.inject.Inject; + import java.util.Arrays; import java.util.List; + import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; @@ -52,18 +54,17 @@ public class RichText implements DialogField { public void setValue(Object value) { String text = (String) value; actions.keyDown(input, CONTROL) // - .sendKeys("a") // - .keyUp(CONTROL) // - .sendKeys(BACK_SPACE); + .sendKeys("a") // + .keyUp(CONTROL) // + .sendKeys(BACK_SPACE); List textDividedByLines = Arrays.asList(text.split("\\\\n")); for (int i = 0; i < textDividedByLines.size(); i++) { - if(i!=0) { + if (i != 0) { actions.sendKeys(RETURN); } actions.sendKeys(textDividedByLines.get(i).trim()); } actions.perform(); } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Select.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Select.java index a1f4a8fd..935c3996 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Select.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Select.java @@ -20,7 +20,9 @@ package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; import com.cognifide.qa.bb.qualifier.PageObject; + import java.util.List; + import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; @@ -51,5 +53,4 @@ public void setValue(Object value) { .orElseThrow(() -> new NoSuchElementException( String.format("Option with text %s not found", value.toString()))).click(); } - } diff --git a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Textfield.java b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Textfield.java index 1065ad54..ed3db90a 100644 --- a/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Textfield.java +++ b/bb-aem-64/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Textfield.java @@ -20,6 +20,7 @@ package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; import com.cognifide.qa.bb.qualifier.PageObject; + import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -42,5 +43,4 @@ public void setValue(Object value) { input.clear(); input.sendKeys(String.valueOf(value)); } - } diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java index a2059f0d..82c5e7b0 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/ConfigDialogImpl.java @@ -139,8 +139,8 @@ public void configureWith(ComponentConfiguration config) { /** * Method used to access DialogField for further configuration. * - * @param label Label of element to access - * @param tab Name of a tab that element is placed on + * @param label Label of element to access + * @param tab Name of a tab that element is placed on * @param fieldType Type of field we would like to access * @return DialogField with our field */ @@ -153,9 +153,9 @@ public DialogField getFieldOnTab(String label, String tab, String fieldType) { /** * Method used to configure a field on a dialog. * - * @param label Label of field to configure + * @param label Label of field to configure * @param fieldType Type of field to configure - * @param value Value that field will be filled with + * @param value Value that field will be filled with * @return ConfigDialog this instance */ @Override @@ -167,7 +167,7 @@ public ConfigDialog setField(String label, String fieldType, Object value) { /** * Method can be used to access a field on currently opened tab * - * @param label Field's label to access + * @param label Field's label to access * @param fieldType Type of field to access * @return DialogField with our field */ @@ -205,9 +205,14 @@ private void configure(ComponentConfiguration config) { private void setFields(List value) { WebElement parent = determineParentScope(); - value.forEach(fieldConfig -> dialogConfigurer - .getDialogField(parent, fieldConfig.getLabel(), fieldConfig.getType()) - .setValue(fieldConfig.getValue())); + value.forEach(fieldConfig -> { + DialogField field = dialogConfigurer + .getDialogField(parent, fieldConfig.getLabel(), fieldConfig.getType()); + if (fieldConfig.getClear()) { + field.clearField(); + } + field.setValue(fieldConfig.getValue()); + }); } private WebElement determineParentScope() { diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/DefaultDialogFieldRetriever.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/DefaultDialogFieldRetriever.java index a834c61b..2ba7d70f 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/DefaultDialogFieldRetriever.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/DefaultDialogFieldRetriever.java @@ -82,7 +82,7 @@ public DialogField getDialogField(WebElement parentElement, String type) { private List getFieldElements(WebElement parentElement, String type) { By selector = getSelectorFromClass(getClassForType(type), pageObjectInjector.getOriginalInjector()) - .orElse(By.cssSelector(Locators.FIELD_WRAPPER_CSS)); + .orElse(By.cssSelector(".coral-Form-fieldwrapper")); return parentElement.findElements(selector); } diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultContentFragmentPathBrowser.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultContentFragmentPathBrowser.java new file mode 100644 index 00000000..81745a91 --- /dev/null +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultContentFragmentPathBrowser.java @@ -0,0 +1,85 @@ +/*- + * #%L + * Bobcat + * %% + * Copyright (C) 2016 Cognifide Ltd. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; + +import static org.openqa.selenium.support.ui.ExpectedConditions.not; +import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable; + +import java.util.List; +import java.util.NoSuchElementException; + +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import com.cognifide.qa.bb.qualifier.Global; +import com.cognifide.qa.bb.qualifier.PageObject; +import com.cognifide.qa.bb.wait.BobcatWait; +import com.cognifide.qa.bb.wait.TimingsBuilder; +import com.google.inject.Inject; + +/** + * Default implementation of {@link ContentFragmentPathBrowser} + */ +@PageObject(css = Locators.AUTOCOMPLETE_CSS) +public class DefaultContentFragmentPathBrowser implements ContentFragmentPathBrowser { + + @FindBy(css = ".coral3-Textfield") + private WebElement input; + + @FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH) + private List label; + + @FindBy(css = ".foundation-picker-buttonlist.coral3-Overlay.is-open") + private WebElement firstResult; + + @Global + @FindBy(css = ".coral3-Dialog--warning.is-open .coral3-Button--primary") + private WebElement warningConfirmation; + + @Inject + private BobcatWait bobcatWait; + + @Override + public void setValue(Object value) { + input.clear(); + input.sendKeys(String.valueOf(value)); + bobcatWait.until(elementToBeClickable(firstResult)); + input.sendKeys(Keys.ENTER); + closeWarningDialogIfRequired(); + } + + @Override + public String getLabel() { + return label.isEmpty() ? "" : label.get(0).getText(); + } + + // The warning dialog doesn't always appear, so it's handled within an if-clause + private void closeWarningDialogIfRequired() { + if (bobcatWait + .tweak(new TimingsBuilder().explicitTimeout(1).build()) + .ignoring(NoSuchElementException.class) + .isConditionMet(elementToBeClickable(warningConfirmation))) { + warningConfirmation.click(); + bobcatWait.tweak(new TimingsBuilder().explicitTimeout(1).build()) + .isConditionMet(not(elementToBeClickable(warningConfirmation))); + } + } +} diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultMultifield.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultMultifield.java index ab34e781..7bee99bc 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultMultifield.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultMultifield.java @@ -36,7 +36,7 @@ /** * Default implementation of {@link Multifield} */ -@PageObject(css = Locators.MULTIFIELD_CSS) +@PageObject(css = "coral-multifield") public class DefaultMultifield implements Multifield { @FindBy(css = "button[coral-multifield-add]") @@ -55,9 +55,9 @@ public void setValue(Object value) { mapper.convertValue(value, new TypeReference>() { }); - items.forEach(MultifieldItem::deleteItem); - - cfg.forEach(entry -> addField()); + while(items.size() < cfg.size()) { + addField(); + } Iterator itemsIterator = items.iterator(); cfg.forEach(entry -> itemsIterator.next().setValue(entry)); @@ -68,6 +68,11 @@ public String getLabel() { return label.isEmpty() ? "" : label.get(0).getText(); } + @Override + public void clearField() { + items.forEach(MultifieldItem::deleteItem); + } + @Override public MultifieldItem getItemAtIndex(int index) { int itemsSize = items.size(); diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultNumberInput.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultNumberInput.java new file mode 100644 index 00000000..2992e064 --- /dev/null +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultNumberInput.java @@ -0,0 +1,51 @@ +/*- + * #%L + * Bobcat + * %% + * Copyright (C) 2016 Cognifide Ltd. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; + +import java.util.List; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import com.cognifide.qa.bb.qualifier.PageObject; + +/** + * Default implementation of {@link NumberInput} + */ +@PageObject(css = "coral-numberinput") +public class DefaultNumberInput implements NumberInput { + + @FindBy(css = "input") + private WebElement input; + + @FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH) + private List label; + + @Override + public void setValue(Object value) { + input.clear(); + input.sendKeys(String.valueOf(value)); + } + + @Override + public String getLabel() { + return label.isEmpty() ? "" : label.get(0).getText(); + } +} diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultPathBrowser.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultPathBrowser.java index 114f6b21..4299f11a 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultPathBrowser.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultPathBrowser.java @@ -23,6 +23,7 @@ import java.util.List; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -52,8 +53,8 @@ public class DefaultPathBrowser implements PathBrowser { public void setValue(Object value) { input.clear(); input.sendKeys(String.valueOf(value)); - - bobcatWait.until(elementToBeClickable(firstResult)).click(); + bobcatWait.until(elementToBeClickable(firstResult)); + input.sendKeys(Keys.ENTER); } @Override diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultSelect.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultSelect.java index 13095689..adfa7c54 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultSelect.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultSelect.java @@ -26,20 +26,23 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import com.cognifide.qa.bb.qualifier.CurrentScope; import com.cognifide.qa.bb.qualifier.PageObject; +import com.google.inject.Inject; /** * Default implementation of {@link Select} */ -@PageObject(xpath = "//coral-select/..") +@PageObject(css = ".coral3-Select") public class DefaultSelect implements Select { private static final String SELECT_OPTIONS_CSS = ".coral3-SelectList-item"; - @FindBy(css = ".coral3-Select") + @Inject + @CurrentScope private WebElement selectField; - @FindBy(css = Locators.LABEL_CSS) + @FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH) private List label; @Override diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultTextfield.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultTextfield.java index 3446548a..ca081274 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultTextfield.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DefaultTextfield.java @@ -24,18 +24,21 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import com.cognifide.qa.bb.qualifier.CurrentScope; import com.cognifide.qa.bb.qualifier.PageObject; +import com.google.inject.Inject; /** * Default implementation of {@link Textfield} */ -@PageObject(css = Locators.FIELD_WRAPPER_CSS) +@PageObject(css = ".coral3-Textfield:not([type='hidden'])") public class DefaultTextfield implements Textfield { - @FindBy(css = ".coral3-Textfield:not([type='hidden']") + @Inject + @CurrentScope private WebElement input; - @FindBy(css = Locators.LABEL_CSS) + @FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH) private List label; @Override diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Fields.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Fields.java index 6733678c..425984ec 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Fields.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Fields.java @@ -34,6 +34,8 @@ public class Fields { public static final String RADIO_GROUP = "RADIO_GROUP"; public static final String RICHTEXT = "RICHTEXT"; public static final String TAGBROWSER = "TAGBROWSER"; + public static final String NUMBER_INPUT = "NUMBER_INPUT"; + public static final String CONTENT_FRAGMENT_PATHBROWSER = "CONTENT_FRAGMENT_PATHBROWSER"; private Fields() { //empty diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Locators.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Locators.java index cdf0185e..0743d4e2 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Locators.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/Locators.java @@ -28,9 +28,7 @@ private Locators() { //util } - public static final String FIELD_WRAPPER_CSS = ".coral-Form-fieldwrapper"; public static final String LABEL_CSS = ".coral-Form-fieldlabel"; - public static final String MULTIFIELD_CSS = "coral-multifield"; public static final String AUTOCOMPLETE_CSS = "foundation-autocomplete"; public static final String ALTERNATE_LABEL_XPATH = "../label"; } diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/DialogFieldsModule.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/DialogFieldsModule.java index a5327686..a4ef88e1 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/DialogFieldsModule.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/DialogFieldsModule.java @@ -23,10 +23,13 @@ import org.slf4j.LoggerFactory; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.Checkbox; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.ContentFragmentPathBrowser; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultContentFragmentPathBrowser; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultCheckbox; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultImage; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultMultifield; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultMultifieldItem; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultNumberInput; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultPathBrowser; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRadioGroup; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRichText; @@ -35,6 +38,7 @@ import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.Image; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.Multifield; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.MultifieldItem; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.NumberInput; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.PathBrowser; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.RadioGroup; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.RichText; @@ -62,6 +66,8 @@ protected void configure() { bind(RichText.class).to(DefaultRichText.class); bind(Select.class).to(DefaultSelect.class); bind(Textfield.class).to(DefaultTextfield.class); + bind(NumberInput.class).to(DefaultNumberInput.class); + bind(ContentFragmentPathBrowser.class).to(DefaultContentFragmentPathBrowser.class); install(new FieldsRegistryModule()); } diff --git a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/FieldsRegistryModule.java b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/FieldsRegistryModule.java index 15c7d12b..af4bff69 100644 --- a/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/FieldsRegistryModule.java +++ b/bb-aem-65/src/main/java/com/cognifide/qa/bb/aem/core/modules/fields/FieldsRegistryModule.java @@ -22,10 +22,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultContentFragmentPathBrowser; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultCheckbox; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultImage; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultMultifield; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultMultifieldItem; +import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultNumberInput; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultPathBrowser; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRadioGroup; import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRichText; @@ -62,12 +64,16 @@ protected void configure() { registerField(fieldsBinder, Fields.MULTIFIELD_ITEM, DefaultMultifieldItem.class); registerField(fieldsBinder, Fields.RADIO_GROUP, DefaultRadioGroup.class); registerField(fieldsBinder, Fields.TAGBROWSER, DefaultTagBrowser.class); + registerField(fieldsBinder, Fields.NUMBER_INPUT, DefaultNumberInput.class); registerField(fieldsBinder, Fields.RICHTEXT, DefaultRichText.class); registerField(fieldsBinder, Options.RTE_OPTIONS, RteOption.class); registerField(fieldsBinder, Options.RTE_OPTIONS_HYPERLINK, Hyperlink.class); registerField(fieldsBinder, Options.RTE_OPTIONS_LISTS, Lists.class); registerField(fieldsBinder, Options.RTE_OPTIONS_PARAGRAPH_FORMATS, ParagraphFormats.class); + + registerField(fieldsBinder, Fields.CONTENT_FRAGMENT_PATHBROWSER, + DefaultContentFragmentPathBrowser.class); } private void registerField(MapBinder binder, String name, diff --git a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/configuration/FieldConfig.java b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/configuration/FieldConfig.java index 991a4c1a..1c300e6c 100644 --- a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/configuration/FieldConfig.java +++ b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/configuration/FieldConfig.java @@ -30,6 +30,8 @@ public class FieldConfig { private Object value; + private boolean clear = false; + /** * @return Label of the field. */ @@ -51,11 +53,19 @@ public Object getValue() { return value; } + /** + * @return Whether the field should be cleared before the value is set + */ + public boolean getClear() { + return clear; + } + @Override public String toString() { return "field:\n" + "\tlabel='" + label + "'\n" + "\ttype='" + type + "'\n" + - "\tvalue=" + value + "'\n"; + "\tvalue=" + value + "'\n" + + "\tclear='" + clear + "'\n"; } } diff --git a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/ContentFragmentPathBrowser.java b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/ContentFragmentPathBrowser.java new file mode 100644 index 00000000..ca347521 --- /dev/null +++ b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/ContentFragmentPathBrowser.java @@ -0,0 +1,29 @@ +/*- + * #%L + * Bobcat + * %% + * Copyright (C) 2019 Cognifide Ltd. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; + +import com.cognifide.qa.bb.qualifier.PageObjectInterface; + +/** + * This class represents path browser dialog field. + */ +@PageObjectInterface +public interface ContentFragmentPathBrowser extends DialogField { +} diff --git a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DialogField.java b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DialogField.java index 72a0bc46..73078edf 100644 --- a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DialogField.java +++ b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/DialogField.java @@ -36,6 +36,7 @@ */ @PageObjectInterface public interface DialogField { + /** * Sets component value. * @@ -49,4 +50,10 @@ public interface DialogField { default String getLabel() { return null; } + + /** + * Clears field input. + */ + default void clearField() { + } } diff --git a/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/NumberInput.java b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/NumberInput.java new file mode 100644 index 00000000..57dd58b1 --- /dev/null +++ b/bb-aem-core/src/main/java/com/cognifide/qa/bb/aem/core/component/dialog/dialogfields/NumberInput.java @@ -0,0 +1,29 @@ +/*- + * #%L + * Bobcat + * %% + * Copyright (C) 2019 Cognifide Ltd. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields; + +import com.cognifide.qa.bb.qualifier.PageObjectInterface; + +/** + * This class represents single line number input dialog field. + */ +@PageObjectInterface +public interface NumberInput extends DialogField { +} diff --git a/docs/_docs/modules/aem/componentconfiguration.md b/docs/_docs/modules/aem/componentconfiguration.md index ddecfd55..fdd99f92 100644 --- a/docs/_docs/modules/aem/componentconfiguration.md +++ b/docs/_docs/modules/aem/componentconfiguration.md @@ -96,6 +96,7 @@ Properties: - label - select dialog field with this label. If there is no label the fields will be selected in order. - type - type of dialog field. All available OOB fields are displayed in section below - value - what value should be set +- clear - true/false, currently viable only for Multifields, you decide if the field's state should be set to a blank before entering the new value. This translates to deleting all existing items in a Multifield before adding any new ones. ### Components without tabs in the dialog @@ -127,6 +128,7 @@ This example shows how we can fill multifield dialog fields: Properties: - label: Option Entries type: MULTIFIELD + clear: false value: - item: - label: Active