Skip to content

Commit 4dd38cf

Browse files
committed
simple retry added
1 parent 5547887 commit 4dd38cf

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

src/test/java/org/htmlunit/libraries/DojoTestBase.java

+30-19
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,38 @@ void test(final String module, final long waitTime) throws Exception {
9191
status = getResultElementText(webdriver);
9292
}
9393

94-
Thread.sleep(Duration.ofSeconds(1).toMillis()); // to make tests a bit more stable
95-
final WebElement output = webdriver.findElement(By.id("logBody"));
96-
final List<WebElement> lines = output.findElements(By.xpath(".//div"));
97-
98-
final StringBuilder result = new StringBuilder();
99-
for (final WebElement webElement : lines) {
100-
final String text = webElement.getText();
101-
if (StringUtils.isNotBlank(text)) {
102-
result.append(text);
103-
result.append("\n");
104-
}
105-
}
94+
for (int i = 0; i < 10; i++) {
95+
try {
96+
Thread.sleep(100);
97+
98+
final WebElement output = webdriver.findElement(By.id("logBody"));
99+
final List<WebElement> lines = output.findElements(By.xpath(".//div"));
100+
101+
final StringBuilder result = new StringBuilder();
102+
for (final WebElement webElement : lines) {
103+
final String text = webElement.getText();
104+
if (StringUtils.isNotBlank(text)) {
105+
result.append(text);
106+
result.append("\n");
107+
}
108+
}
109+
110+
String expFileName = StringUtils.replace(module, ".", "");
111+
expFileName = StringUtils.replace(expFileName, "_", "");
112+
expFileName = StringUtils.replace(expFileName, "/", "_");
113+
String expected = loadExpectation(expFileName);
114+
expected = StringUtils.replace(expected, "\r\n", "\n");
106115

107-
String expFileName = StringUtils.replace(module, ".", "");
108-
expFileName = StringUtils.replace(expFileName, "_", "");
109-
expFileName = StringUtils.replace(expFileName, "/", "_");
110-
String expected = loadExpectation(expFileName);
111-
expected = StringUtils.replace(expected, "\r\n", "\n");
116+
assertEquals(normalize(expected), normalize(result.toString()));
117+
// assertEquals(expected, result.toString());
112118

113-
assertEquals(normalize(expected), normalize(result.toString()));
114-
// assertEquals(expected, result.toString());
119+
// success
120+
break;
121+
}
122+
catch (AssertionError ignored) {
123+
// fails, give it another try
124+
}
125+
}
115126
}
116127
catch (final Exception e) {
117128
e.printStackTrace();

0 commit comments

Comments
 (0)