Skip to content

Commit 54f5be7

Browse files
committed
Handle the case where a htmlrunner command times out
1 parent 37cdce0 commit 54f5be7

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

java/server/src/org/openqa/selenium/server/htmlrunner/NonReflectiveSteps.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class NonReflectiveSteps {
3131
private static final Logger LOG = Logger.getLogger("Selenium Core Step");
3232

3333
private static Supplier<ImmutableMap<String, CoreStepFactory>> STEPS =
34-
Suppliers.memoize(() -> build());
34+
Suppliers.memoize(NonReflectiveSteps::build);
3535

3636
public ImmutableMap<String, CoreStepFactory> get() {
3737
return STEPS.get();
@@ -42,10 +42,14 @@ private static ImmutableMap<String, CoreStepFactory> build() {
4242

4343
CoreStepFactory nextCommandFails = (locator, value) ->
4444
(selenium, state) -> new NextCommandFails();
45-
4645
steps.put("assertErrorOnNext", nextCommandFails);
4746
steps.put("assertFailureOnNext", nextCommandFails);
4847

48+
CoreStepFactory verifyNextCommandFails = (locator, value) ->
49+
(selenium, state) -> new VerifyNextCommandFails();
50+
steps.put("verifyErrorOnNext", verifyNextCommandFails);
51+
steps.put("verifyFailureOnNext", verifyNextCommandFails);
52+
4953
steps.put("echo", ((locator, value) -> (selenium, state) -> {
5054
LOG.info(locator);
5155
return NextStepDecorator.IDENTITY;
@@ -91,4 +95,23 @@ public boolean isOkayToContinueTest() {
9195
return true;
9296
}
9397
}
98+
99+
private static class VerifyNextCommandFails extends NextStepDecorator {
100+
101+
@Override
102+
public NextStepDecorator evaluate(CoreStep nextStep, Selenium selenium, TestState state) {
103+
NextStepDecorator actualResult = nextStep.execute(selenium, state);
104+
105+
// This is kind of fragile. Oh well.
106+
if (actualResult.equals(NextStepDecorator.IDENTITY)) {
107+
return NextStepDecorator.VERIFICATION_FAILED;
108+
}
109+
return NextStepDecorator.IDENTITY;
110+
}
111+
112+
@Override
113+
public boolean isOkayToContinueTest() {
114+
return true;
115+
}
116+
}
94117
}

java/server/src/org/openqa/selenium/server/htmlrunner/ReflectivelyDiscoveredSteps.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.thoughtworks.selenium.SeleneseTestBase;
2626
import com.thoughtworks.selenium.Selenium;
2727
import com.thoughtworks.selenium.SeleniumException;
28+
import com.thoughtworks.selenium.Wait;
2829

2930
import java.lang.reflect.Method;
3031
import java.util.Arrays;
@@ -224,6 +225,9 @@ private static NextStepDecorator invokeMethod(Method method, Selenium selenium,
224225
if (cause instanceof SeleniumException) {
225226
return NextStepDecorator.ERROR(cause);
226227
}
228+
if (cause instanceof Wait.WaitTimedOutException) {
229+
return NextStepDecorator.ERROR(cause);
230+
}
227231
}
228232
throw new CoreRunnerError(
229233
String.format(

0 commit comments

Comments
 (0)