Skip to content

Commit

Permalink
give menu toggles a moment to become interactable before clicking (#1598
Browse files Browse the repository at this point in the history
)
  • Loading branch information
labkey-chrisj authored Aug 7, 2023
1 parent edd7162 commit f910950
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/org/labkey/test/components/react/BaseBootstrapMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import org.labkey.test.util.TestLogger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

/**
* Wraps basic open/close functionality of 'Dropdown' and 'DropdownButton' components from '@types/react-bootstrap'
Expand Down Expand Up @@ -54,6 +58,8 @@ public void expand()
if (!isExpanded())
{
getWrapper().scrollIntoView(elementCache().toggleAnchor);
new WebDriverWait(getDriver(), Duration.ofSeconds(2))
.until(ExpectedConditions.elementToBeClickable(elementCache().toggleAnchor));
for (int retry = 0; retry < _expandRetryCount; retry++)
{
elementCache().toggleAnchor.click();
Expand All @@ -73,7 +79,11 @@ public void expand()
public void collapse()
{
if (isExpanded())
{
new WebDriverWait(getDriver(), Duration.ofSeconds(2))
.until(ExpectedConditions.elementToBeClickable(elementCache().toggleAnchor));
elementCache().toggleAnchor.click();
}
WebDriverWrapper.waitFor(()-> !isExpanded(), "Menu did not collapse as expected", WebDriverWrapper.WAIT_FOR_JAVASCRIPT);
}

Expand Down

0 comments on commit f910950

Please sign in to comment.