Permalink
Browse files

add option of timing delay between repeats; default of 50

  • Loading branch information...
1 parent bd5f0d2 commit 4b59a36d7bedd4fd02fa47236b2484de31eb48dd @paul-hammant paul-hammant committed Mar 30, 2012
@@ -88,6 +88,10 @@ public void returnsNothing(OnFluentSomething recording) {
}
public FluentRecording recording() {
- return new FluentRecording(unmodifiableList(list), retryStrategies);
+ return recording(50);
+ }
+
+ public FluentRecording recording(int millisToSleepBetweenRetries) {
+ return new FluentRecording(unmodifiableList(list), millisToSleepBetweenRetries, retryStrategies);
}
}
@@ -9,10 +9,12 @@
private final List<OnFluentSomething> onFluentSomethings;
private final RetryStrategy[] retryStrategies;
+ private final int millisToSleep;
- public FluentRecording(List<OnFluentSomething> onFluentSomethings, RetryStrategy... retryStrategies) {
+ public FluentRecording(List<OnFluentSomething> onFluentSomethings, int millisToSleep, RetryStrategy... retryStrategies) {
this.onFluentSomethings = onFluentSomethings;
this.retryStrategies = retryStrategies;
+ this.millisToSleep = millisToSleep;
}
public Object playback(FluentWebDriver driver) {
@@ -35,6 +37,12 @@ public Object playback(FluentWebDriver driver) {
lastRE = e;
goAgain = retry(e, start, retries);
}
+ if (goAgain) {
+ try {
+ Thread.sleep(millisToSleep);
+ } catch (InterruptedException e) {
+ }
+ }
}
throw lastRE;
}
@@ -46,5 +54,4 @@ private boolean retry(Throwable e, long start, int retries) {
}
return shouldRetry;
}
-
}
@@ -440,14 +440,14 @@ public void assertion_errors_decorated_for_filter() {
}
private void filter_exception_handling(Class<? extends Throwable> throwable) {
- FluentWebElements ome = fwd.divs(By.id("foo"));
+ FluentWebElements fwe = fwd.divs(By.id("foo"));
- assertThat(ome, notNullValue());
+ assertThat(fwe, notNullValue());
FAIL_ON_NEXT.set(throwable);
try {
- ome.filter(makeMatcherThatUsesWebDriver("Hello"));
+ fwe.filter(makeMatcherThatUsesWebDriver("Hello"));
fail("should have barfed");
} catch (FluentExecutionStopped e) {
assertThat(e.getMessage(), containsString("?.divs(By.id: foo).filter(myMatcher('Hello'))"));
@@ -457,14 +457,14 @@ private void filter_exception_handling(Class<? extends Throwable> throwable) {
@Test
public void nothing_matching_in_filter_exception_handling() {
- FluentWebElements ome = fwd.divs(By.id("foo"));
+ FluentWebElements fwe = fwd.divs(By.id("foo"));
- assertThat(ome, notNullValue());
+ assertThat(fwe, notNullValue());
FAIL_ON_NEXT.set(NothingMatches.class);
try {
- ome.filter(makeMatcherThatUsesWebDriver("Hello"));
+ fwe.filter(makeMatcherThatUsesWebDriver("Hello"));
fail("should have barfed");
} catch (FluentExecutionStopped.BecauseNothingMatchesInFilter e) {
assertThat(e.getMessage(), containsString("?.divs(By.id: foo).filter(myMatcher('Hello'))"));
@@ -474,14 +474,14 @@ public void nothing_matching_in_filter_exception_handling() {
@Test
public void nothing_matching_in_first_exception_handling() {
- FluentWebElements ome = fwd.divs(By.id("foo"));
+ FluentWebElements fwe = fwd.divs(By.id("foo"));
- assertThat(ome, notNullValue());
+ assertThat(fwe, notNullValue());
FAIL_ON_NEXT.set(NothingMatches.class);
try {
- ome.first(makeMatcherThatUsesWebDriver("Hello"));
+ fwe.first(makeMatcherThatUsesWebDriver("Hello"));
fail("should have barfed");
} catch (FluentExecutionStopped.BecauseNothingMatchesInFilter e) {
assertThat(e.getMessage(), containsString("?.divs(By.id: foo).first(myMatcher('Hello'))"));
@@ -513,14 +513,14 @@ public void assertion_error_decorated_for_first() {
}
private void first_exception_handling(Class<? extends Throwable> throwable) {
- FluentWebElements ome = fwd.divs(By.id("foo"));
+ FluentWebElements fwe = fwd.divs(By.id("foo"));
- assertThat(ome, notNullValue());
+ assertThat(fwe, notNullValue());
FAIL_ON_NEXT.set(throwable);
try {
- ome.first(makeMatcherThatUsesWebDriver("Goodbye"));
+ fwe.first(makeMatcherThatUsesWebDriver("Goodbye"));
fail("should have barfed");
} catch (FluentExecutionStopped e) {
assertThat(e.getMessage(), containsString("?.divs(By.id: foo).first(myMatcher('Goodbye'))"));
@@ -531,7 +531,7 @@ private void first_exception_handling(Class<? extends Throwable> throwable) {
public void further_find_element_after_multiple_is_unsupported() {
try {
- FluentWebElement ose = fwd.divs(By.xpath("foo")).span(By.xpath("bar"));
+ fwd.divs(By.xpath("foo")).span(By.xpath("bar"));
fail("should have barfed");
} catch (UnsupportedOperationException e) {
// expected

0 comments on commit 4b59a36

Please sign in to comment.