DialogService

Learn how to use BELLATRIX DialogService.

Example

[TestFixture]
public class DialogServiceTests : WebTest
{
    [Test]
    public void AcceptDialogAlert()
    {
        App.Navigation.Navigate("http://demos.bellatrix.solutions/welcome/");

        var couponButton = App.Components.CreateById<Button>("couponBtn");
        couponButton.Click();

        App.Dialogs.Handle();
    }

    [Test]
    public void HappyBirthdayCouponDisplayed_When_ClickOnCouponButton()
    {
        App.Navigation.Navigate("http://demos.bellatrix.solutions/welcome/");

        var couponButton = App.Components.CreateById<Button>("couponBtn");
        couponButton.Click();

        App.Dialogs.Handle((a) => Assert.AreEqual("Try the coupon- happybirthday", a.Text));
    }

    [Test]
    [Ignore]
    public void DismissDialogAlert()
    {
        App.Navigation.Navigate("http://demos.bellatrix.solutions/welcome/");

        var couponButton = App.Components.CreateById<Button>("couponBtn");
        couponButton.Click();

        App.Dialogs.Handle(dialogButton: DialogButton.Cancel);
    }
}

Explanations

BELLATRIX gives you some methods for handling dialogs.

App.Dialogs.Handle();

You can click on the OK button and handle the alert.

App.Dialogs.Handle((a) => Assert.AreEqual("Try the coupon- happybirthday", a.Text));

You can pass an anonymous lambda function and do something with the alert.

App.Dialogs.Handle(dialogButton: DialogButton.Cancel);

You can tell the dialog service to click a different button.