diff --git a/src/main/java/com/automation/ui/pages/SystemUsersPage.java b/src/main/java/com/automation/ui/pages/SystemUsersPage.java index f059dca..1db27ea 100644 --- a/src/main/java/com/automation/ui/pages/SystemUsersPage.java +++ b/src/main/java/com/automation/ui/pages/SystemUsersPage.java @@ -3,8 +3,11 @@ import java.util.List; import org.openqa.selenium.By; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; /** * Admin → User Management → System Users ({@value #PATH}): a filter form @@ -36,10 +39,16 @@ public SystemUsersPage(WebDriver driver) { } /** - * @return boolean true once the page URL and the filter form are shown. + * @return boolean true once the page URL, the filter form and the loaded + * user table are shown. Filters typed while the table is still + * loading can be cleared when the page finishes rendering. */ public boolean isDisplayed() { - return waitForUrl(PATH) && isVisible(filterInput("Username")); + if (!waitForUrl(PATH) || !isVisible(filterInput("Username"))) { + return false; + } + waitForLoader(); + return isVisible(recordCount); } /** @@ -49,6 +58,7 @@ public boolean isDisplayed() { */ public void filterByUsername(String username) { type(filterInput("Username"), username); + wait.until(d -> username.equals(usernameFilter())); } /** @@ -63,13 +73,40 @@ public void filterByStatus(String status) { /** * Clicks Search and waits for the table to reload. + *
+ * The unfiltered table and its counter are already on screen, so waiting
+ * for them alone can read the old rows when the spinner is missed. This
+ * also waits until the old first row is replaced or the counter changes.
+ * If neither happens, the search returned the rows already shown.
*/
public void search() {
+ List