Skip to content

Commit c6e81e2

Browse files
committed
Core testrunner now support WaitFor* and WaitForNot*
1 parent 40f3ada commit c6e81e2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,36 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
158158
state.store(locator, toStore);
159159
return NextStepDecorator.IDENTITY;
160160
}));
161+
162+
factories.put(
163+
"waitFor" + shortName.substring(0, 1).toUpperCase() + shortName.substring(1),
164+
(((locator, value) -> ((selenium, state) -> {
165+
new Wait() {
166+
@Override
167+
public boolean until() {
168+
invokeMethod(method, selenium, buildArgs(method, locator, value));
169+
return true;
170+
}
171+
}.wait("Can't wait for " + shortName);
172+
return NextStepDecorator.IDENTITY;
173+
}))));
174+
175+
factories.put(
176+
"waitForNot" + shortName.substring(0, 1).toUpperCase() + shortName.substring(1),
177+
(((locator, value) -> ((selenium, state) -> {
178+
try {
179+
new Wait() {
180+
@Override
181+
public boolean until() {
182+
invokeMethod(method, selenium, buildArgs(method, locator, value));
183+
return true;
184+
}
185+
}.wait("Can't wait for " + shortName);
186+
return NextStepDecorator.ASSERTION_FAILED;
187+
} catch (Wait.WaitTimedOutException e) {
188+
return NextStepDecorator.IDENTITY;
189+
}
190+
}))));
161191
}
162192

163193
factories.put(

0 commit comments

Comments
 (0)