Skip to content

Commit a53bee6

Browse files
Improved Column Widths (#2824)
- EditableGrid: Fix getCheckbox locator - GridRow: Update getCellStyle locator - ResponsiveGrid.clickColumnMenuItem: click the th instead of the chevron - Handle floating grid headers Co-authored-by: labkey-tchad <tchad@labkey.com>
1 parent fd963aa commit a53bee6

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

src/org/labkey/test/Locators.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private Locators() { }
3131
public static final Locator.XPathLocator panelWebpartTitle = Locator.byClass("labkey-wp-title-text");
3232
public static final Locator.XPathLocator folderTitle = Locator.tagWithClass("a", "lk-body-title-folder");
3333
public static final Locator.XPathLocator loadingSpinner = Locator.byClass("fa-spinner");
34+
public static final Locator.CssLocator floatingGridHeader = Locator.css(".grid-panel__grid .table-responsive thead, .editable-grid__container .table-responsive thead");
3435

3536
public static Locator.XPathLocator headerContainer()
3637
{

src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected ElementCache newElementCache()
4242

4343
public T setSystemFieldVisibility(String fieldName, boolean isVisible)
4444
{
45-
var xpath = "//div[contains(@class, 'domain-system-fields__grid')]//td[text()='" + fieldName + "']/preceding-sibling::td//input";
45+
var xpath = "//div[contains(@class, 'domain-system-fields__grid')]//td[.//div[text()='" + fieldName + "']]/preceding-sibling::td//input";
4646
var checkBox = Checkbox.Checkbox(Locator.xpath(xpath));
4747
var enabledCheckBox = checkBox.find(getFieldsPanel());
4848
enabledCheckBox.set(isVisible);

src/org/labkey/test/components/ui/grids/EditableGrid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ protected class ElementCache extends Component<?>.ElementCache
12521252

12531253
Checkbox getCheckbox(int rowIndex)
12541254
{
1255-
return new Checkbox(Locator.css("td > input[type=checkbox]").findElement(getRow(rowIndex)));
1255+
return new Checkbox(Locator.css("td > .table-cell-content > input[type=checkbox]").findElement(getRow(rowIndex)));
12561256
}
12571257

12581258
protected WebElement getColumnHeaderCell(CharSequence columnIdentifier)

src/org/labkey/test/components/ui/grids/GridRow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public WebElement getCell(CharSequence columnIdentifier)
107107
public String getCellStyle(CharSequence columnIdentifier)
108108
{
109109
var cell = getCell(columnIdentifier);
110-
return Locator.tagWithClass("span", "ws-pre-wrap").findElement(cell).getAttribute("style");
110+
return Locator.byClass("table-cell-content").child(Locator.tag("span")).findElement(cell).getAttribute("style");
111111
}
112112

113113
/**

src/org/labkey/test/components/ui/grids/ResponsiveGrid.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,8 @@ public void clickColumnMenuItem(CharSequence columnIdentifier, String menuText,
320320
WebElement headerCell = elementCache().getColumnHeaderCell(columnIdentifier);
321321
// Scroll to middle in order to make room for the dropdown menu
322322
getWrapper().scrollToMiddle(headerCell);
323-
324-
WebElement toggle = Locator.tagWithClass("span", "fa-chevron-circle-down")
325-
.findElement(headerCell);
326-
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(toggle));
327-
toggle.click();
323+
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(headerCell));
324+
headerCell.click();
328325

329326
// Use getDriver() because the grid menus are rendered in a "react portal" at the end of the HTML body, so they
330327
// are totally detached from the rest of the grid.

src/org/labkey/test/util/selenium/ScrollUtils.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.labkey.test.util.DataRegionTable;
88
import org.labkey.test.util.TestLogger;
99
import org.openqa.selenium.JavascriptExecutor;
10+
import org.openqa.selenium.Point;
11+
import org.openqa.selenium.Rectangle;
1012
import org.openqa.selenium.WebDriver;
1113
import org.openqa.selenium.WebElement;
1214
import org.openqa.selenium.interactions.Locatable;
@@ -53,17 +55,15 @@ public static boolean scrollUnderFloatingHeader(WebElement webElement)
5355
Locators.floatingHeaderContainer(),
5456
Locators.appFloatingHeader(),
5557
Locators.domainDesignerFloatingHeader(),
56-
DataRegionTable.Locators.floatingHeader().notHidden());
58+
DataRegionTable.Locators.floatingHeader().notHidden(),
59+
Locators.floatingGridHeader);
5760

58-
int headerHeight = 0;
59-
for (WebElement floatingHeader : floatingHeaders)
61+
if (!floatingHeaders.isEmpty())
6062
{
61-
headerHeight += floatingHeader.getSize().getHeight();
62-
}
63-
if (headerHeight > 0)
64-
{
65-
int elYInViewPort = webElement.getLocation().getY() - getWindowScrollY(webDriver).intValue();
66-
if (headerHeight > elYInViewPort)
63+
Rectangle rect = webElement.getRect();
64+
Point elementCenter = new Point(rect.getX() + rect.getWidth()/2, rect.getY() + rect.getHeight()/2);
65+
66+
if (floatingHeaders.stream().anyMatch(el -> pointInRect(elementCenter, el.getRect())))
6767
{
6868
TestLogger.debug("Scrolled under floating headers:\n" + floatingHeaders.stream().map(WebElement::toString).collect(Collectors.joining("\n")));
6969
((Locatable) webElement).getCoordinates().inViewPort(); // 'inViewPort()' will scroll element into view
@@ -73,6 +73,12 @@ public static boolean scrollUnderFloatingHeader(WebElement webElement)
7373
return false;
7474
}
7575

76+
private static boolean pointInRect(Point point, Rectangle rect)
77+
{
78+
return rect.getX() <= point.getX() && point.getX() <= rect.getX() + rect.getWidth() &&
79+
rect.getY() <= point.getY() && point.getY() <= rect.getY() + rect.getHeight();
80+
}
81+
7682
public static Long getWindowScrollY(WebDriver webDriver)
7783
{
7884
Number N = (Number) executeScript(webDriver, "return window.scrollY;");

0 commit comments

Comments
 (0)