Search code examples
c#ui-automationcoypu

Coypu wait until one of the two elements is present


I use Coypu for my tests.

How can I wait until either a certain css appears or a certain text?

Right now my solution is this:

browser.Visit(uriContext.Uri.ToString());
var deadline = DateTime.UtcNow.Add(WebAppWarmUpTimeout);
while (DateTime.UtcNow < deadline)
{
    if (browser.HasContent("404 - File or directory not found.", SmallTimeoutOptions))
    {
        Assert.Fail("404");
    }
    else if (browser.FindCss("body nav a", "Job Search", SmallTimeoutOptions).Exists())
    {
        break;
    }
}

Is there a better way to do it?


Solution

  • I admit of not having read the entire documentation attentively, it is all there - https://github.com/featurist/coypu#finding-states-nondeterministic-testing

    From the source:

    enter image description here

    P.S.

    Thank you to Adrian Longley who answered promptly my question on their github page - https://github.com/featurist/coypu/issues/187