Skip to content

Commit

Permalink
toString method of the fluent wait object will now contain the name of
Browse files Browse the repository at this point in the history
the last Function (=expected condition)'s toString (useful with
validations
  • Loading branch information
aharon hacmon committed Jan 26, 2014
1 parent 241bd91 commit 5035ae2
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@
import org.openqa.selenium.support.ui.Clock;
import org.openqa.selenium.support.ui.Sleeper;

import com.google.common.base.Function;

public class FluentWait<T> extends org.openqa.selenium.support.ui.FluentWait<T> {

private String lastFunctionTitle;

public FluentWait(T input, Clock clock, Sleeper sleeper) {
super(input, clock, sleeper);
}

public FluentWait(T input) {
super(input);
}

@Override
public <V> V until(Function<? super T, V> isTrue) {
lastFunctionTitle = isTrue.toString();
return super.until(isTrue);
}
/**
* return the title of the expected condition that was applied on the input.
*/
@Override
public String toString() {
return lastFunctionTitle;
}

/**
* Throws a timeout exception. This method may be overridden to throw an exception that is
* idiomatic for a particular test infrastructure, such as an AssertionError in JUnit4.
Expand Down

0 comments on commit 5035ae2

Please sign in to comment.