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..d0c62c89 --- /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) 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 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..1378e52a 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]") 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..ff388c61 --- /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) 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 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/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/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 { +}