How to wait for an element to become hidden upon page initialization.
There is a page with loading indicator displayed while the page is loading. During the navigation to this page the test has to wait until the loading indicator element is hidden and only then start interaction with the page.
<div class="loading-indicator">
<span class="glyphicon glyphicon-repeat"></span>
Please wait...
</div>
You can choose one of the solutions below.
using Atata;
namespace SampleApp.UITests
{
using _ = SomePage;
[WaitForElement(WaitBy.Class, "loading-indicator", WaitUntil.MissingOrHidden, TriggerEvents.Init)]
public class SomePage : Page<_>
{
}
}
using Atata;
namespace SampleApp.UITests
{
using _ = SomePage;
public class SomePage : Page<_>
{
[FindByClass]
[WaitFor(Until.MissingOrHidden)] // By default executes on TriggerEvents.Init.
public Control<_> LoadingIndicator { get; private set; }
}
}
Waiting until the element is hidden/missing will be performed upon SomePage
page initialization.
Go.To<SomePage>();
In order to avoid a duplication of trigger declaration in different page objects, it is possible to extract a trigger definition to the custom trigger class. See Custom Trigger: Wait for Loading Indicator example.