Controls

Custom controls used by other features are defined in this section.

Controls section

A good example is Hoverable control used in most pages. Since many controls have to be hovered so that save, edit and cancel buttons become visible, we wrapped the behavior in this generic control.

Other components which need this behavior simply inherit from this control and define their own fields and subcomponents.

Here is a snippet demonstrating how to use Hoverable on role status control:

Role status control
public enum RoleStatus
{
    Enabled = 1,
    Disabled
}

[ControlDefinition("role-edit-status")]
public class RoleStatusControl<TOwner> : Hoverable<TOwner> where TOwner : PageObject<TOwner>
{
    [FindByXPath(Constants.Components.RolePage.Status.State)]
    public Content<RoleStatus, TOwner> Text { get; private set; }

    [FindByXPath(Constants.Components.RolePage.Status.Toggle, Visibility = Visibility.Any)]
    public Clickable<TOwner> Toggle { get; private set; }
}

Then you can define this RoleStatusControl and use it on another page object:

namespace Applicita.AAF.WebApp.Tests.Roles.Components
{
    using _ = RolePage;

    [WaitForLoadingIndicator(on: TriggerEvents.Init)]
    public class RolePage : PageWithNavigation<_>
    {
        public RoleStatusControl<_> Status { get; private set; }
    }
}

After defining control on page object, we can test it:

[Test]
public void RolePage_Status_Edit()
{
    Pages.TestRolePage()
        .Status.Text.Should.Equal(RoleStatus.Enabled)
        .Status.Edit.Click()
        .Status.Toggle.Click()
        .Status.Save()
        .Status.Text.Should.Equal(RoleStatus.Disabled);
}

Last updated

Was this helpful?