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

Clear for dialog fields #394

Merged
merged 10 commits into from
Oct 22, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -204,9 +204,14 @@ private void configure(ComponentConfiguration config) {

private void setFields(List<FieldConfig> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -40,15 +41,19 @@ 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();
}
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -61,4 +62,8 @@ public void setValue(Object value) {
draggable.dropTo(droppable);
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ public void setValue(Object value) {
mapper.convertValue(value, new TypeReference<List<MultifieldEntry>>() {
});

items.forEach(MultifieldItem::deleteItem);

cfg.forEach(entry -> addField());
while(items.size() < cfg.size()) {
addField();
}

Iterator<MultifieldItem> itemsIterator = items.iterator();
cfg.forEach(entry -> itemsIterator.next().setValue(entry));
}

@Override
public void clearField() {
items.forEach(MultifieldItem::deleteItem);
}

/**
* Returns MultifieldItem at declared index position
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public void setValue(Object value) {
entry.getItem().forEach(this::setFieldInMultifield);
}

@Override
public void clearField() {
}

/**
* Deletes this item
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@ public void setValue(Object value) {
currentScope.findElement(By.className("coral-Form-fieldlabel")).click();
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ public void setValue(Object value) {
radioLabel.findElement(By.xpath(".//..")).click();
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,18 +54,22 @@ 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<String> 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();
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,4 +54,9 @@ public void setValue(Object value) {
String.format("Option with text %s not found", value.toString()))).click();
}

@Override
public void clearField() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,4 +44,8 @@ public void setValue(Object value) {
input.sendKeys(String.valueOf(value));
}

@Override
public void clearField() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public void setValue(Object value) {
}
}

@Override
public void clearField() {

}

private void clickFormatButton(WebElement button) {
controlToolbar.selectText();
bobcatWait.until(input -> button.isEnabled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void setValue(Object value) {
}
}

@Override
public void clearField() {

}

private void openJustifyPopover() {
controlToolbar.selectText();
bobcatWait.until(input -> controlToolbar.getToggleJustifyButton().isEnabled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public void setValue(Object value) {
}
}

@Override
public void clearField() {

}

private void openListPopover() {
controlToolbar.selectText();
bobcatWait.until((ExpectedCondition<Object>) input -> controlToolbar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -205,9 +205,14 @@ private void configure(ComponentConfiguration config) {

private void setFields(List<FieldConfig> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public DialogField getDialogField(WebElement parentElement, String type) {
private List<WebElement> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public void setValue(Object value) {
public String getLabel() {
return label.isEmpty() ? "" : label.get(0).getText();
}

@Override
public void clearField() {
}
}
Loading