Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 22, 2025
1 parent 0d7fd31 commit feba503
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/test/java/org/htmlunit/WebDriverTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1087,18 +1087,28 @@ protected final WebDriver loadPageVerifyTitle2(final String html, final String..

protected final WebDriver verifyTitle2(final long maxWaitTime, final WebDriver driver,
final String... expectedAlerts) throws Exception {

final StringBuilder expected = new StringBuilder();
for (int i = 0; i < expectedAlerts.length; i++) {
expected.append(expectedAlerts[i]).append('\u00A7');
}
final String expectedTitle = expected.toString();

final long maxWait = System.currentTimeMillis() + maxWaitTime;

while (System.currentTimeMillis() < maxWait) {
try {
return verifyTitle2(driver, expectedAlerts);
final String title = driver.getTitle();
assertEquals(expectedTitle, title);
return driver;
}
catch (final AssertionError e) {
// ignore and wait
}
}

return verifyTitle2(driver, expectedAlerts);
assertEquals(expectedTitle, driver.getTitle());
return driver;
}

protected final WebDriver verifyTitle2(final WebDriver driver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void basicFileNameFromHeader() throws Exception {

final File tmpFolder = new File(System.getProperty("java.io.tmpdir"));
final File downloadFolder = new File(tmpFolder, "downloading-attachment-test");
FileUtils.deleteDirectory(downloadFolder);

try {
FileUtils.forceMkdir(downloadFolder);
Expand Down

0 comments on commit feba503

Please sign in to comment.