How to wait for an element upon page initialization.
There is a page with slow loading of content. During the navigation to this page the test has to wait until some important content element is visible and only then start interaction with the page.
<div id="content-block">
<span>Some content</span>
</div>
You can choose one of the solutions below.
using Atata;
namespace SampleApp.UITests
{
using _ = SomePage;
[WaitForElement(WaitBy.Id, "content-block", WaitUntil.Visible, TriggerEvents.Init)]
public class SomePage : Page<_>
{
}
}
using Atata;
namespace SampleApp.UITests
{
using _ = SomePage;
public class SomePage : Page<_>
{
[FindById]
[WaitFor(Until.Visible)] // By default executes on TriggerEvents.Init.
public Control<_> ContentBlock { get; private set; }
}
}
Waiting for the element will be performed upon SomePage
page initialization.
Go.To<SomePage>();