Skip to content

Commit

Permalink
Merge pull request #5508 from jdi-testing/5360
Browse files Browse the repository at this point in the history
#5360 fix locators and color reading
  • Loading branch information
pnatashap authored Apr 28, 2024
2 parents db8ddec + 29df152 commit b9629bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
import com.epam.jdi.light.vuetify.elements.complex.ColorPicker;

public class ColorPickersPage extends VuetifyPage {
// @todo #5298 Locators should use .v-color-picker class
@UI("#CanvasColorPicker > div:first-child")
@UI("#CanvasColorPicker .v-color-picker")
public static ColorPicker noCanvasColorPicker;

@UI("#CanvasColorPicker > div:nth-child(2)")
public static ColorPicker fullCanvasColorPicker;

@UI("#ElevationColorPicker > div:first-child")
@UI("#ElevationColorPicker .v-color-picker")
public static ColorPicker flatColorPicker;

@UI("#ElevationColorPicker > div:nth-child(2)")
public static ColorPicker elevationColorPicker;

@UI("#InputsColorPicker > div:nth-child(1)")
@UI("#InputsColorPicker .v-color-picker")
public static ColorPicker noInputsColorPicker;

@UI("#InputsColorPicker > div:nth-child(3)")
Expand All @@ -47,10 +46,10 @@ public class ColorPickersPage extends VuetifyPage {
@UI("#ModelColorPicker div.col-md-4 button:nth-of-type(5)")
public static VuetifyButton hsvaModelButton;

@UI("#ModelColorPicker div.d-flex")
@UI("#ModelColorPicker .v-color-picker")
public static ColorPicker modelColorPicker;

@UI("#SwatchesColorPicker > div:first-child")
@UI("#SwatchesColorPicker .v-color-picker")
public static ColorPicker mediumSwatchesColorPicker;

@UI("#SwatchesColorPicker > div:nth-child(2)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// @todo #5310 Simplify and refactor this element, too many hardcoded values. Check if all colors are possible to get
public class ColorPicker extends UIBaseElement<ColorPickerAssert> implements HasElevation, HasTheme {

public static final String STYLE = "style";
public static final String DIV = "div";
public static final String RGBA = "RGBA";
public static final String RGB = "RGB";
Expand Down Expand Up @@ -108,6 +107,7 @@ public void setColor(String value) {
String green = String.valueOf(color.getGreen());
String blue = String.valueOf(color.getBlue());
double doubleAlpha = color.getAlpha() / 255.0D;
// @todo #5360 View of alpha channel depends on regional settings
String alpha = String.format("%.2f", doubleAlpha).replace(",", ".");
inputRH().setText(red);
inputGS().setText(green);
Expand All @@ -127,9 +127,7 @@ public String getInputModel() {

@JDIAction("Get color from '{name}'")
public Color getColor(UIElement element) {
String styleColor = getElementStyle(element);
String stringColor = styleColor.substring(12, styleColor.length() - 1);
return Color.fromString(stringColor);
return Color.fromString(element.css("background-color"));
}

@JDIAction("Get colors from '{name}' swatches")
Expand All @@ -146,7 +144,7 @@ public ArrayList<Color> getColorsFromSwatches() {
}

public String getElementStyle(UIElement element) {
return element.attr(STYLE);
return element.attr("style");
}

}

0 comments on commit b9629bf

Please sign in to comment.