diff options
Diffstat (limited to 'testbench-api')
-rw-r--r-- | testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java index 03f10ecc7c..d733e7a531 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java @@ -15,9 +15,66 @@ */ package com.vaadin.testbench.elements; +import java.util.List; + +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; import com.vaadin.testbench.elementsbase.ServerClass; -@ServerClass("com.vaadin.ui.ColorPickerPreview") +@ServerClass("com.vaadin.ui.components.colorpicker.ColorPickerPreview") public class ColorPickerPreviewElement extends CssLayoutElement { + /** + * Get whether TextField in ColorPickerPreview has validation errors. + * + * @return true if field has errors, false otherwise + * + * @since + */ + public boolean getColorFieldContainsErrors() { + List<WebElement> caption = findElements( + By.className("v-caption-v-colorpicker-preview-textfield")); + boolean noCaption = caption.isEmpty(); + return noCaption ? noCaption + : caption.get(0).findElements(By.className("v-errorindicator")) + .isEmpty(); + } + + /** + * Get the value of the input element TextField in ColorPickerPreview. + * + * @return the value of the attribute 'value' of the input element + * + * @since + */ + public String getColorFieldValue() { + return getColorTextField().getAttribute("value"); + } + + /** + * Set value of TextField in ColorPickerPreview. Any existing value in the + * field is replaced. + * + * @param value + * text to insert + * + * @since + */ + public void setColorTextFieldValue(String value) { + // Select all text + getColorTextField().sendKeys(Keys.chord(Keys.CONTROL, "a")); + getColorTextField().sendKeys(value); + } + + /** + * @return <code>WebElement</code> representing TextField in + * ColorPickerPreviewComponent + * + * @since + */ + public WebElement getColorTextField() { + return findElement(By.className("v-colorpicker-preview-textfield")); + } } |