Site Loader
Auckland, New Zealand
In the last post we discussed how to work with popup windows using Coypu for Selenium C# an advanced wrapper for Selenium. In this post we will discuss how to work with Dialog boxes of application using Coypu. Here is the complete video Here is the complete code from the above video
        [TestMethod]
        public void Test_DialogBox()
        {
            var sessionConfiguration = new SessionConfiguration()
            {
                Browser = Browser.Firefox,
                AppHost = "executeautomation.com",
            };

            var browser = new BrowserSession(sessionConfiguration);
            browser.Visit("/demosite/Login.html");

            browser.FillIn("UserName").With("admin");
            browser.FillIn("Password").With("password");
            browser.ClickButton("Login");


            //Click Dialog
            browser.ClickButton("Generate");

            bool hasDialog = browser.HasDialog("You generated a Javascript alert");

            //Assert if dialog present
            NUnit.Framework.Assert.That(hasDialog, "Should have this text");

            //Click Okay
            browser.AcceptModalDialog();

            hasDialog = browser.HasDialog("You pressed OK!");

            //Assert if dialog present
            NUnit.Framework.Assert.That(hasDialog, "Should have this text");

            browser.AcceptModalDialog();
        }
Thanks for reading the post and watching the video!!! Please leave your comments and let me know if there is anything I should update in this post. Thanks, Karthik KK

Post Author: Karthik kk

Leave a Reply

Your email address will not be published. Required fields are marked *