diff --git a/src/org/labkey/test/components/domain/ConditionalFormatPanel.java b/src/org/labkey/test/components/domain/ConditionalFormatPanel.java index b776ff900b..5f1efcff8e 100644 --- a/src/org/labkey/test/components/domain/ConditionalFormatPanel.java +++ b/src/org/labkey/test/components/domain/ConditionalFormatPanel.java @@ -1,5 +1,6 @@ package org.labkey.test.components.domain; +import org.labkey.remoteapi.domain.ConditionalFormat; import org.labkey.remoteapi.query.Filter; import org.labkey.test.Locator; import org.labkey.test.components.WebDriverComponent; @@ -24,18 +25,53 @@ public ConditionalFormatPanel(WebElement element, ConditionalFormatDialog dialog _dialog = dialog; } + public ConditionalFormatPanel setConditionalFormat(ConditionalFormat conditionalFormat) + { + for (int i = 0; i < conditionalFormat.getQueryFilter().size(); i++) + { + var filterCondition = conditionalFormat.getQueryFilter().get(i); + if (i==0) + { + setFirstCondition(filterCondition.getOperator()); + if (filterCondition.getValue() != null) + setFirstValue(filterCondition.getValue().toString()); + } + if (i==1) + { + setSecondCondition(filterCondition.getOperator()); + if (filterCondition.getValue() != null) + setSecondValue(filterCondition.getValue().toString()); + } + } + setBoldCheckbox(conditionalFormat.getBold()); + setItalicsCheckbox(conditionalFormat.getItalic()); + setStrikethroughCheckbox(conditionalFormat.getStrikethrough()); + setTextColor(conditionalFormat.getTextColor()); + setFillColor(conditionalFormat.getBackgroundColor()); + return this; + } + public ConditionalFormatPanel setFirstCondition(Filter.Operator operator) { expand(); elementCache().firstConditionSelect().selectByValue(operator.getUrlKey()); return this; } + public String getFirstCondition() + { + return elementCache().firstConditionSelect().getFirstSelectedOption().getText(); + } + public ConditionalFormatPanel setFirstValue(String value) { expand(); elementCache().firstFilterValueInput().setValue(value); return this; } + public String getFirstValue() + { + return elementCache().firstFilterValueInput().getValue(); + } public ConditionalFormatPanel setSecondCondition(Filter.Operator operator) { @@ -43,12 +79,21 @@ public ConditionalFormatPanel setSecondCondition(Filter.Operator operator) elementCache().secondConditionSelect().selectByValue(operator.getUrlKey()); return this; } + public String getSecondCondition() + { + return elementCache().secondConditionSelect().getFirstSelectedOption().getText(); + } + public ConditionalFormatPanel setSecondValue(String value) { expand(); elementCache().secondFilterValueInput().setValue(value); return this; } + public String getSecondValue() + { + return elementCache().secondFilterValueInput().getValue(); + } public ConditionalFormatPanel setBoldCheckbox(boolean checked) { @@ -56,12 +101,24 @@ public ConditionalFormatPanel setBoldCheckbox(boolean checked) elementCache().boldCheckbox().set(checked); return this; } + + public boolean getBoldChecked() + { + return elementCache().boldCheckbox().get(); + } + public ConditionalFormatPanel setItalicsCheckbox(boolean checked) { expand(); elementCache().italicsCheckbox().set(checked); return this; } + + public boolean getItalicsChecked() + { + return elementCache().italicsCheckbox().get(); + } + public ConditionalFormatPanel setStrikethroughCheckbox(boolean checked) { expand(); @@ -69,6 +126,11 @@ public ConditionalFormatPanel setStrikethroughCheckbox(boolean checked) return this; } + public boolean getStrikethroughChecked() + { + return elementCache().strikethroughCheckbox().get(); + } + public ConditionalFormatPanel setTextColor(String colorHex) { expand(); @@ -78,6 +140,12 @@ public ConditionalFormatPanel setTextColor(String colorHex) return this; } + public String getTextStyle() + { + expand(); + return elementCache().textColorPreview.getAttribute("style"); + } + public ConditionalFormatPanel setFillColor(String colorHex) { expand(); @@ -87,6 +155,18 @@ public ConditionalFormatPanel setFillColor(String colorHex) return this; } + public String getFillStyle() + { + expand(); + return elementCache().fillColorPreview.getAttribute("style"); + } + + public String getPreviewTextStyle() + { + expand(); + return elementCache().previewTextInput.getAttribute("style"); + } + public ConditionalFormatDialog clickRemove() { expand(); @@ -171,7 +251,10 @@ public Checkbox strikethroughCheckbox() final Locator collapseIconLocator = Locator.tagWithClass("div", "domain-validator-collapse-icon"); final WebElement textColor = Locator.tagWithName("button", "domainpropertiesrow-textColor").findWhenNeeded(this); + final WebElement textColorPreview = Locator.tagWithClass("div", "domain-color-preview").index(0).findWhenNeeded(this); final WebElement fillColor = Locator.tagWithName("button", "domainpropertiesrow-backgroundColor").findWhenNeeded(this); + final WebElement fillColorPreview = Locator.tagWithClass("div", "domain-color-preview").index(1).findWhenNeeded(this); + final WebElement previewTextInput = Locator.tagWithAttribute("input", "value", "Preview Text").findWhenNeeded(this); final WebElement removeButton = Locator.button("Remove Formatting").findWhenNeeded(this); } diff --git a/src/org/labkey/test/components/ui/grids/DetailTable.java b/src/org/labkey/test/components/ui/grids/DetailTable.java index 5bf3c13446..10d505df50 100644 --- a/src/org/labkey/test/components/ui/grids/DetailTable.java +++ b/src/org/labkey/test/components/ui/grids/DetailTable.java @@ -99,12 +99,21 @@ else if (elementCache().siblingField(identifier).isDisplayed()) { return elementCache().siblingField(identifier); } + else if (elementCache().dataFieldByKey(identifier).isDisplayed()) + { + return elementCache().dataFieldByKey(identifier); + } else { throw new NoSuchElementException(String.format("Could not find field '%s'.", identifier)); } } + public boolean fieldHasFormatPill(String identifier) + { + return Locator.tagWithClass("*", "status-pill").existsIn(getField(identifier)); + } + /** * Return the value of a cell identified by the text in the left most column. * @@ -234,7 +243,7 @@ public final WebElement dataByLabel(String fieldLabel) public final WebElement dataFieldByKey(String fieldKey) { - return Locator.tagWithAttribute("td", "data-fieldkey", fieldKey).findElement(this); + return Locator.tagWithAttribute("td", "data-fieldkey", fieldKey).findWhenNeeded(this); } // Some tables will show a value in a td with no attributes, use the td that has the text (label) to find the value. diff --git a/src/org/labkey/test/components/ui/grids/GridRow.java b/src/org/labkey/test/components/ui/grids/GridRow.java index 932b3bf1bf..4e0906efbd 100644 --- a/src/org/labkey/test/components/ui/grids/GridRow.java +++ b/src/org/labkey/test/components/ui/grids/GridRow.java @@ -45,6 +45,11 @@ public boolean hasSelectColumn() return _grid.hasSelectColumn(); } + public boolean hasConditionalFormatPill(CharSequence columnIdentifier) + { + return Locator.tagWithClass("*", "status-pill").existsIn(getCell(columnIdentifier)); + } + /** * Returns the selected state of the row selector checkbox, if one is present * @return true if the select checkbox is checked. @@ -90,6 +95,16 @@ public WebElement getCell(CharSequence columnIdentifier) return getCell(_grid.getColumnIndex(columnIdentifier)); } + /** + * gets the style attribute of the value-wrapper for the specified cell + * @return + */ + public String getCellStyle(CharSequence columnIdentifier) + { + var cell = getCell(columnIdentifier); + return Locator.tagWithClass("span", "ws-pre-wrap").findElement(cell).getAttribute("style"); + } + /** * Returns true if the row contains all of the specified column/value pairs * @param partialMap Map of key (column) value (text)