简体   繁体   中英

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?

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:

在此处输入图片说明

PS

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM