Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22680: Regression on createAndDeleteUser #3675

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public String getPasswordConfirmation()
public void setPasswordConfirmation(String newPasswordConfirmation)
{
this.newPasswordConfirmationField.sendKeys(newPasswordConfirmation);
getDriver().waitUntilCondition(
driver -> !this.newPasswordConfirmationField.getAttribute("class").isEmpty()
);
}

public ResetPasswordCompletePage clickSave()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,24 @@ protected WebElement getFormElement()

public void fillFieldsByName(Map<String, String> valuesByNames)
{
Map<WebElement, String> valuesByElements = new LinkedHashMap<>((int) (valuesByNames.size() / 0.75));

Map<WebElement, String> valuesByElements = new LinkedHashMap<>();

String lastElementName = null;
for (String name : valuesByNames.keySet()) {
valuesByElements.put(getFormElement().findElement(By.name(name)), valuesByNames.get(name));
lastElementName = name;
surli marked this conversation as resolved.
Show resolved Hide resolved
}
fillFieldsByElements(valuesByElements);

/* Register password confirmation is usually the last element that needs to be validated by liveValidation.
This wait allows to solve a race condition between the form submission and the computation of the status of
those fields. We force the status to be solved before we try anything else, especially submitting the form.
Unfortunately in Java17 we do not have lastEntry(), so we use a few non optimized operations instead.
This is okay because the Map should not contain a lot of elements.
*/
if (valuesByNames.containsKey("register2_password")) {
getDriver().waitUntilCondition(driver -> !getFormElement().findElement(By.name("register2_password"))
.getAttribute(CLASS_ATTRIBUTE).isEmpty());
if(valuesByElements.size() > 0) {
surli marked this conversation as resolved.
Show resolved Hide resolved
WebElement lastElement = getFormElement().findElement(By.name(lastElementName));
getDriver().waitUntilCondition(driver -> !lastElement.getAttribute(CLASS_ATTRIBUTE).isEmpty());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void changePassword(String originalPassword, String password, String pass
this.password1.sendKeys(password);
this.password2.clear();
this.password2.sendKeys(password2);
getDriver().waitUntilElementHasNonEmptyAttributeValue(By.xpath("//input[@id='xwikipassword2']"),"class");
}

/**
Expand Down