diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/ColorPickersTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/ColorPickersTests.java index b918938b2e..a372a3559c 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/ColorPickersTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/ColorPickersTests.java @@ -2,6 +2,7 @@ import io.github.com.dataproviders.ColorPickersDataProviders; import io.github.epam.TestsInit; +import org.hamcrest.Matchers; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -50,19 +51,20 @@ public void fullCanvasColorPickerTest(String colorValue, double initialAlphaSliderStyle = fullCanvasColorPicker.alphaSlider().value(); fullCanvasColorPicker.setColor(colorValue); fullCanvasColorPicker.has().dotColor(colorValue) - .and().hueSliderValueHaveChanged(initialHueSliderStyle); + .and().hueSliderValue(Matchers.not(initialHueSliderStyle)); fullCanvasColorPicker.setColor(transparentColorValue); fullCanvasColorPicker.has().dotColor(transparentColorValue) - .and().alphaSliderValueHaveChanged(initialAlphaSliderStyle); + .and().alphaSliderValue(Matchers.not(initialAlphaSliderStyle)); } + // @todo #5310 Test is not stable, as initial state can differ from RGBA @Test(description = "Test checks color picking from a non-canvas slider") public void noCanvasColorPickerTest() { noCanvasColorPicker.show(); noCanvasColorPicker.has().inputModel(RGBA); - noCanvasColorPicker.colorModelButton().click(); + noCanvasColorPicker.changeEditStyleButton().click(); noCanvasColorPicker.has().inputModel(HSLA); - noCanvasColorPicker.colorModelButton().click(); + noCanvasColorPicker.changeEditStyleButton().click(); noCanvasColorPicker.has().inputModel(HEX) .and().hexInputFieldStringColorValue(INITIAL_HEX_STRING_COLOR); } @@ -78,10 +80,8 @@ public void elevationColorPickerTest() { @Test(description = "Test checks color picker without input fields") public void noInputColorPickerTest() { noInputsColorPicker.show(); - noInputsColorPicker.has().canvasStyle() - .and().canvasDotStyle() - .and().hueSliderValue() - .and().alphaSliderValue() + noInputsColorPicker.has().hueSliderValue(Matchers.notNullValue()) + .and().alphaSliderValue(Matchers.notNullValue()) .and().dotColor(INITIAL_RGBA_STRING_COLOR); } @@ -101,45 +101,45 @@ public void modelColorPickerTest() { modelColorPicker.show(); hexModelButton.click(); modelColorPicker.has().inputModel(RGB); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HSL); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HEX) .and().hexInputFieldLength(NO_ALPHA_HEX_LENGTH); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); hexaModelButton.click(); modelColorPicker.has().inputModel(RGBA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HSLA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HEX) .and().hexInputFieldLength(ALPHA_HEX_LENGTH); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); rgbaModelButton.click(); modelColorPicker.has().inputModel(RGBA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HSLA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HEX) .and().hexInputFieldLength(ALPHA_HEX_LENGTH); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); hslaModelButton.click(); modelColorPicker.has().inputModel(RGBA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HSLA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HEX); modelColorPicker.has().hexInputFieldLength(ALPHA_HEX_LENGTH); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); hsvaModelButton.click(); modelColorPicker.has().inputModel(RGBA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HSLA); - modelColorPicker.colorModelButton().click(); + modelColorPicker.changeEditStyleButton().click(); modelColorPicker.has().inputModel(HEX) .and().hexInputFieldLength(ALPHA_HEX_LENGTH); } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/ColorPickerAssert.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/ColorPickerAssert.java index 0ef00d04ea..d03bc1039b 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/ColorPickerAssert.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/ColorPickerAssert.java @@ -5,60 +5,31 @@ import com.epam.jdi.light.vuetify.elements.complex.ColorPicker; import com.epam.jdi.light.vuetify.interfaces.asserts.ElevationAssert; import com.epam.jdi.light.vuetify.interfaces.asserts.ThemeAssert; +import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.openqa.selenium.support.Color; import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; +// @todo #5310 Add more assertion with Matcher inside (like alphaSliderValue), we can not see all required public class ColorPickerAssert extends UIAssert implements ElevationAssert, ThemeAssert { - @JDIAction(value = "Assert that '{name}' canvas has style", isAssert = true) - public ColorPickerAssert canvasStyle() { - jdiAssert(element().getCanvasStyle(), Matchers.is(Matchers.notNullValue()), - "ColorPicker has not canvas style"); - return this; - } - - @JDIAction(value = "Assert that '{name}' canvasDot has style", isAssert = true) - public ColorPickerAssert canvasDotStyle() { - jdiAssert(element().getCanvasDotStyle(), Matchers.is(Matchers.notNullValue()), - "ColorPicker has not dot style"); - return this; - } - @JDIAction(value = "Assert that '{name}' input model is '{0}'", isAssert = true) public ColorPickerAssert inputModel(String inputModel) { - String actualInputModel = element().getInputModel(); - jdiAssert(actualInputModel, Matchers.is(inputModel)); - return this; - } - - @JDIAction(value = "Assert that '{name}' hueSlider has value", isAssert = true) - public ColorPickerAssert hueSliderValue() { - jdiAssert(element().hueSlider().value(), Matchers.is(Matchers.notNullValue()), - "ColorPicker has not slider value"); - return this; - } - - @JDIAction(value = "Assert that '{name}' alphaSlider has value", isAssert = true) - public ColorPickerAssert alphaSliderValue() { - jdiAssert(element().alphaSlider().value(), Matchers.is(Matchers.notNullValue()), - "ColorPicker has not slider value"); + jdiAssert(element().getInputModel(), Matchers.is(inputModel)); return this; } - // @todo #5048 Check this method naming and logic - @JDIAction(value = "Assert that '{name}' hueSlider value have changed", isAssert = true) - public ColorPickerAssert hueSliderValueHaveChanged(double initialValue) { - jdiAssert(element().hueSlider().value(), Matchers.not(initialValue), "Hue slider value wasn't changed"); + @JDIAction(value = "Assert that '{name}' hueSlider matches {0}", isAssert = true) + public ColorPickerAssert hueSliderValue(Matcher value) { + jdiAssert(element().hueSlider().value(), value); return this; } - @JDIAction(value = "Assert that '{name}' alphaSlider value have changed", isAssert = true) - public ColorPickerAssert alphaSliderValueHaveChanged(double initialValue) { - jdiAssert(element().alphaSlider().value(), Matchers.not(initialValue), - "Alpha slider value wasn't changed"); + @JDIAction(value = "Assert that '{name}' alphaSlider matches {0}", isAssert = true) + public ColorPickerAssert alphaSliderValue(Matcher value) { + jdiAssert(element().alphaSlider().value(), value); return this; } diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/ColorPicker.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/ColorPicker.java index 9a76eb141d..59ddd0f526 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/ColorPicker.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/ColorPicker.java @@ -15,12 +15,11 @@ /** * To see example of ColoPicker web element please visit https://v2.vuetifyjs.com/en/components/color-pickers/ */ - +// @todo #5310 Simplify and refactor this element, too many hardcoded values. Check if all colors are possible to get public class ColorPicker extends UIBaseElement implements HasElevation, HasTheme { public static final String STYLE = "style"; public static final String DIV = "div"; - public static final String SPAN = "span"; public static final String RGBA = "RGBA"; public static final String RGB = "RGB"; public static final String HSLA = "HSLA"; @@ -39,13 +38,13 @@ public class ColorPicker extends UIBaseElement implements Has protected static final String HUE_SLIDER_LOCATOR = "div.v-color-picker__hue"; protected static final String ALPHA_SLIDER_LOCATOR = "div.v-color-picker__alpha"; protected static final String DOT_LOCATOR = "div.v-color-picker__dot div"; - protected static final String INPUTS_MODEL_LOCATOR = "div.v-color-picker__edit div"; + protected static final String INPUTS_MODEL_LOCATOR = ".v-color-picker__edit .v-color-picker__input"; protected static final String INPUT_FIRST_LOCATOR = "div.v-color-picker__edit div:nth-of-type(1)"; protected static final String INPUT_SECOND_LOCATOR = "div.v-color-picker__edit div:nth-of-type(2)"; protected static final String INPUT_THIRD_LOCATOR = "div.v-color-picker__edit div:nth-of-type(3)"; protected static final String INPUT_FOURTH_LOCATOR = "div.v-color-picker__edit div:nth-of-type(4)"; protected static final String INPUT_HEX_LOCATOR = "div.v-color-picker__input"; - protected static final String BUTTON_LOCATOR = "button"; + protected static final String EDIT_STYLE_BUTTON_LOCATOR = "button"; protected static final String SWATCHES_LOCATOR = ".v-color-picker__swatches .v-color-picker__color"; @Override @@ -93,8 +92,9 @@ public TextField inputHEX() { return new TextField().setCore(TextField.class, core().find(INPUT_HEX_LOCATOR)); } - public Button colorModelButton() { - return new Button().setCore(Button.class, core().find(BUTTON_LOCATOR)); + @JDIAction("Get {name}'s button to change style for editor between RGBA/HEX/HSLA") + public Button changeEditStyleButton() { + return new Button().setCore(Button.class, core().find(EDIT_STYLE_BUTTON_LOCATOR)); } public WebList swatches() { @@ -115,22 +115,12 @@ public void setColor(String value) { inputA().setText(alpha); } - @JDIAction("Get canvas style from '{name}'") - public String getCanvasStyle() { - return getElementStyle(canvas()); - } - - @JDIAction("Get canvasDot style from '{name}'") - public String getCanvasDotStyle() { - return getElementStyle(canvasDot()); - } - @JDIAction("Get input model from '{name}'") public String getInputModel() { StringBuilder inputModel = new StringBuilder(); WebList inputsList = core().finds(INPUTS_MODEL_LOCATOR); for (UIElement inputField : inputsList) { - inputModel.append(inputField.find(SPAN).getText()); + inputModel.append(inputField.getText()); } return inputModel.toString(); }