@@ -31,7 +31,7 @@ class NonReflectiveSteps {
31
31
private static final Logger LOG = Logger .getLogger ("Selenium Core Step" );
32
32
33
33
private static Supplier <ImmutableMap <String , CoreStepFactory >> STEPS =
34
- Suppliers .memoize (() -> build () );
34
+ Suppliers .memoize (NonReflectiveSteps :: build );
35
35
36
36
public ImmutableMap <String , CoreStepFactory > get () {
37
37
return STEPS .get ();
@@ -42,10 +42,14 @@ private static ImmutableMap<String, CoreStepFactory> build() {
42
42
43
43
CoreStepFactory nextCommandFails = (locator , value ) ->
44
44
(selenium , state ) -> new NextCommandFails ();
45
-
46
45
steps .put ("assertErrorOnNext" , nextCommandFails );
47
46
steps .put ("assertFailureOnNext" , nextCommandFails );
48
47
48
+ CoreStepFactory verifyNextCommandFails = (locator , value ) ->
49
+ (selenium , state ) -> new VerifyNextCommandFails ();
50
+ steps .put ("verifyErrorOnNext" , verifyNextCommandFails );
51
+ steps .put ("verifyFailureOnNext" , verifyNextCommandFails );
52
+
49
53
steps .put ("echo" , ((locator , value ) -> (selenium , state ) -> {
50
54
LOG .info (locator );
51
55
return NextStepDecorator .IDENTITY ;
@@ -91,4 +95,23 @@ public boolean isOkayToContinueTest() {
91
95
return true ;
92
96
}
93
97
}
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
+ }
94
117
}
0 commit comments