Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Core components list handling fixes #381

Merged
merged 6 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
/**
* Default implementation of {@link Multifield}
*/
@PageObject(css = Locators.FIELD_WRAPPER_CSS)
@PageObject(css = Locators.MULTIFIELD_CSS)
public class DefaultMultifield implements Multifield {

@FindBy(css = "button.coral3-Button.coral3-Button--secondary")
@FindBy(css = "button[coral-multifield-add]")
private WebElement addButton;

@FindPageObject
private List<MultifieldItem> items;

@FindBy(css = Locators.LABEL_CSS)
@FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH)
private List<WebElement> label;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
*/
package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields;

import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;
import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

Expand All @@ -34,15 +33,18 @@
/**
* Default implementation of {@link PathBrowser}
*/
@PageObject(css = Locators.FIELD_WRAPPER_CSS)
@PageObject(css = Locators.AUTOCOMPLETE_CSS)
public class DefaultPathBrowser implements PathBrowser {

@FindBy(className = "coral3-Textfield")
@FindBy(css = ".coral3-Textfield")
private WebElement input;

@FindBy(css = Locators.LABEL_CSS)
@FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH)
private List<WebElement> label;

@FindBy(css = ".foundation-picker-buttonlist.coral3-Overlay.is-open")
private WebElement firstResult;

@Inject
private BobcatWait bobcatWait;

Expand All @@ -51,9 +53,7 @@ public void setValue(Object value) {
input.clear();
input.sendKeys(String.valueOf(value));

bobcatWait.until(visibilityOfElementLocated(
By.cssSelector(".foundation-picker-buttonlist.coral3-Overlay.is-open")));
label.get(0).click();
bobcatWait.until(elementToBeClickable(firstResult)).click();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*-
* #%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.elementToBeClickable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import com.cognifide.qa.bb.qualifier.PageObject;
import com.cognifide.qa.bb.wait.BobcatWait;
import com.google.inject.Inject;

/**
* Default implementation of {@link TagBrowser}
*/
@PageObject(css = Locators.AUTOCOMPLETE_CSS)
public class DefaultTagBrowser implements TagBrowser {

@FindBy(css = ".coral3-Textfield")
private WebElement input;

@FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH)
private List<WebElement> label;

@FindBy(css = ".coral3-Tag-removeButton")
private List<WebElement> removeTagButtons;

@FindBy(css = ".foundation-picker-buttonlist.coral3-Overlay.is-open")
private WebElement firstResult;

@Inject
private BobcatWait bobcatWait;

@Override
public void setValue(Object value) {
List<String> tags = Arrays
.asList(String.valueOf(value).trim().replaceAll("\\[|\\]|\\s", "").split(","));

removeTagButtons.forEach((element) -> element.sendKeys(Keys.ENTER));

tags.forEach((tag) -> {
input.clear();
input.sendKeys(tag);
bobcatWait.until(elementToBeClickable(firstResult)).click();
});
}

@Override
public String getLabel() {
return label.isEmpty() ? "" : label.get(0).getText();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* This class contains names of all available field types.
*/
public class Fields {

public static final String CHECKBOX = "CHECKBOX";
public static final String IMAGE = "IMAGE";
public static final String PATHBROWSER = "PATHBROWSER";
Expand All @@ -32,6 +33,7 @@ public class Fields {
public static final String MULTIFIELD_ITEM = "MULTIFIELD_ITEM";
public static final String RADIO_GROUP = "RADIO_GROUP";
public static final String RICHTEXT = "RICHTEXT";
public static final String TAGBROWSER = "TAGBROWSER";

private Fields() {
//empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
* Contains common locators related to dialog fields
*/
public class Locators {

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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRadioGroup;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultRichText;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultSelect;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultTagBrowser;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DefaultTextfield;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.DialogField;
import com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.Fields;
Expand All @@ -42,6 +43,7 @@
import com.google.inject.multibindings.MapBinder;

public class FieldsRegistryModule extends AbstractModule {

private static final Logger LOG = LoggerFactory.getLogger(FieldsRegistryModule.class);

@Override
Expand All @@ -59,6 +61,7 @@ protected void configure() {
registerField(fieldsBinder, Fields.MULTIFIELD, DefaultMultifield.class);
registerField(fieldsBinder, Fields.MULTIFIELD_ITEM, DefaultMultifieldItem.class);
registerField(fieldsBinder, Fields.RADIO_GROUP, DefaultRadioGroup.class);
registerField(fieldsBinder, Fields.TAGBROWSER, DefaultTagBrowser.class);

registerField(fieldsBinder, Fields.RICHTEXT, DefaultRichText.class);
registerField(fieldsBinder, Options.RTE_OPTIONS, RteOption.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void execute(SlingPageData data) throws AemPageManipulationException {
httpClient.execute(request);
} catch (IOException e) {
throw new AemPageManipulationException(e);
} finally {
request.releaseConnection();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void execute(SlingPageData data) throws AemPageManipulationException {
httpClient.execute(request);
} catch (IOException e) {
throw new AemPageManipulationException(e);
} finally {
request.releaseConnection();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ public void startElement(String uri, String localName, String qName, Attributes
if (isIgnoredAttribute(attributeName)) {
continue;
}
String value = attributes.getValue(attributeName);
if (value.startsWith("[") && value.endsWith("]")) {
value = value.replaceAll("[\\[\\]]", "");
}
parserResults
.add(new BasicNameValuePair(entryName.toString() + SEPARATOR + attributeName,
attributes.getValue(attributeName)));
value));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*-
* #%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 tag browser dialog field
*/
@PageObjectInterface
public interface TagBrowser extends DialogField {

}
1 change: 1 addition & 0 deletions docs/_docs/modules/aem/componentconfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Version: >= 2.1.0
| PATHBROWSER | path |
| SELECT | text from dropdown |
| RADIO_GROUP | text from radio option |
| TAGBROWSER | text for each tag to select, each tag is a separate list member of "value" |
| MULTIFIELD | list of "item" each with own fields (see example above) |
| RICHTEXT | text |
| RTE_OPTIONS | simple fields on RTE toolbar, without any sub-options; e.g.: Bold/Underline/Italic/Unlink (just provide the title of the button) |
Expand Down