Skip to content

Instantly share code, notes, and snippets.

@kberridge
Created October 22, 2013 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kberridge/7103428 to your computer and use it in GitHub Desktop.
Save kberridge/7103428 to your computer and use it in GitHub Desktop.
Coypu HasValue extension
public static bool HasValue(this ElementScope scope, string text, Options options = null)
{
var f = scope.GetType().GetField("options", BindingFlags.Instance | BindingFlags.NonPublic);
var config = (Options)f.GetValue(scope);
var robustly = new RetryUntilTimeoutRobustWrapper();
return robustly.Robustly(new HasValueQuery(scope, text, options ?? config));
}
class HasValueQuery : Query<bool>
{
protected readonly Options options;
protected readonly string value;
protected ElementScope Scope { get; private set; }
public TimeSpan Timeout { get; private set; }
public TimeSpan RetryInterval { get; private set; }
public HasValueQuery(ElementScope scope, string value, Options options)
{
this.options = options;
this.value = value;
Scope = scope;
Timeout = options.Timeout;
RetryInterval = options.RetryInterval;
}
public bool Run()
{
return Scope.Now().Value == value;
}
public bool ExpectedResult { get { return true; } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment