1. Results behind a spinner

The button asks the server for three results; the server answers after 1.5 seconds. Meanwhile a spinner is shown. Every click draws the list again, so elements found before the click are gone afterwards.

Loads: 0

    2. A message that appears later

    The message appears 2 seconds after the click, without a spinner.

    3. A call made with jQuery

    The same request, made with $.ajax, without a spinner. VAF waits until jQuery has no request running before it looks for a section, so the text below is already updated when the test reads it.

    Status: Not loaded

    What to practise

    Waiting in VAF: guide, section 6.

    Tested in VAF-Demo

    A test of this page from VAF-Demo: the whole VAF chain, from the page to the element, is in the test.

    [Test]
    public void ResultsAreReadAfterTheLoaderIsGone()
    {
        // From now on VAF waits for the spinner to disappear before it looks for an element.
        SharedContext.Browser.LetsUseLoader<LoadingPage.Spinner>();
    
        SharedContext.App.Should().HaveSection<LoadingPage.SpinnerDemo>()
            .That.Should().HaveElement<LoadingPage.SpinnerDemo.Load>()
                .That.AsButton().LetsClick();
    
        SharedContext.App.Should().HaveSection<LoadingPage.SpinnerDemo>()
            .That.Should().HaveElement<LoadingPage.SpinnerDemo.LoadCount>()
                .That.AsCounterField().Should().HaveValue("1")
            .AndAlso().Should().HaveElement<LoadingPage.SpinnerDemo.FirstResult>()
                .That.AsLabelText().Should().HaveValue("Alpha (load 1)");
    }

    On GitHub (opens in a new tab)