Represents the button control. Default search is performed by the content and value (button by content text and input by value attribute). Handles any input element with type="button", type="submit", type="reset" or button element.

<button>Save</button>

or

<input type="button" value="Save">

Supports [GoTemporarily] settings attribute.

Button Control

using Atata;
using _ = SampleApp.SamplePage;

namespace SampleApp
{
    public class SamplePage : Page<_>
    {
        public Button<_> Save { get; private set; }
    }
}
Go.To<SamplePage>().
    Save.Click();

Button Delegate

It is recommended to use Button delegate as it simplifies the use by eliminating Click and ClickAndGo methods.

using Atata;
using _ = SampleApp.SamplePage;

namespace SampleApp
{
    public class SamplePage : Page<_>
    {
        public ButtonDelegate<_> Save { get; private set; }
    }
}
Go.To<SamplePage>().
    Save();

As it is a delegate type, the use of Should, Content and IsEnabled properties should be performed like methods (extensions), e.g. Save.Should().Exist().

Navigation

It is possible to pass another generic argument of PageObject type, meaning that after the click on the button the navigation to this PageObject is performed. It works the same way for the control and delegate.

using Atata;
using _ = SampleApp.SamplePage1;

namespace SampleApp
{
    public class SamplePage1 : Page<_>
    {
        public ButtonDelegate<SamplePage2, _> Save { get; private set; }
    }
}
using Atata;
using _ = SampleApp.SamplePage2;

namespace SampleApp
{
    public class SamplePage2 : Page<_>
    {
        public Button<SamplePage1, _> GoBack { get; private set; }
    }
}
Go.To<SamplePage1>().
    Save().
        GoBack.ClickAndGo();

Note that Save delegate property is used as the method that returns the instance of SamplePage2 class. But for GoBack property it is required to call ClickAndGo method as it is a property of Button class type.

Methods

public static TNavigateTo

ClickAndGo<TNavigateTo, TOwner>(this INavigable<TNavigateTo, TOwner> navigableControl)

where TNavigateTo : PageObject<TNavigateTo> where TOwner : PageObject<TOwner>

Clicks the control and performs the navigation to the page object of TNavigateTo type.