Search code examples
c#seleniumautomated-testsatata

Atata – Is there any functionality equivalent to Wait.Until?


In scenarios I'm working with, there's a need to wait until expected conditions like the value is present, the value has expected text or state, or until more complex rules are valid, e.g.:

Wait.Until(x => x.UserName.Value.Get() != string.Empty)

Given Selenium wait.until method, is there any equivalent functionality in Atata framework?

I've seen there are plenty of attributes for waiting like Until, WaitFor, WaitForElement, but these are for simple scenarios. I need the similar functionality for more complex rules. How that can be achieved using Atata?


Solution

  • You can use component's Should.* extension methods for that.

    page.SomeSpan.Should.Equal("smth"); // Checks for text in some <span> element.
    

    By default, it can take up to 5 seconds with retries until condition will execute, even if control's element didn't exist at the beginning of verification. Exception is thrown only after the time is out and condition is not met.

    page.SomeSpan.Should.Within(30).StartWith("smth"); // Wait for condition within 30 seconds.
    page.SomeSpan.Should.AtOnce.Contain("smth"); // Without retries, quickly checks and throws if condition doesn't match.
    page.SomeSpan.Should.Not.BeNullOrEmpty(); // Wait for any value in <span>.
    

    You can also use Should extension methods for control lists and data properties:

    page.SomeTable.Rows.Should.Not.BeEmpty();
    page.SomeTable.Rows.Count.Should.BeGreaterOrEqual(1);
    

    And so on... You can check Atata.IDataVerificationProviderExtensions and Atata.IUIComponentVerificationProviderExtensions classes for other methods. And for negative checks just add "Not" after "Should": Should.Not.*. There is also Should.Satisfy() method for custom conditions.