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 all 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,25 @@ 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<>();

WebElement lastElement = null;
for (String name : valuesByNames.keySet()) {
valuesByElements.put(getFormElement().findElement(By.name(name)), valuesByNames.get(name));
lastElement = getFormElement().findElement(By.name(name));
valuesByElements.put(lastElement, valuesByNames.get(name));
}
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() from LinkedHashMaps,
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.isEmpty() && lastElement != null) {
WebElement finalLastElement = lastElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need that variable, do you?

Copy link
Contributor Author

@Sereza7 Sereza7 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code was underlined with Variable used in lambda expression should be final or effectively final this was the quickest fix to get rid of this warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, you use it in a lambda.

getDriver().waitUntilCondition(driver -> !finalLastElement.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
Loading