public void Home_HasMvcStoreHasTitle_True()
        {
            var browser = new IE("http://localhost:1100/");

            browser.BringToFront();
            Assert.IsTrue(browser.ContainsText("ASP.NET MVC MUSIC STORE"));

            browser.Close();
        }
        public void Home_ClickOnRockContainsRockAlbumText_True()
        {
            using (var browser = new IE("http://localhost:1100/"))
            {

                browser.BringToFront();

                browser.Link(Find.ByText("Rockssss")).Click();
                Assert.IsTrue(browser.ContainsText("Rock Albums"));

            }
        }
Example #3
0
        /// <summary>
        /// Opens a new IE instance with the given settings in front of other windows that are currently open.
        /// </summary>
        /// <param name="targetURL">The URL that the IE instance should browse to.</param>
        /// <param name="silentMode">If true the test will be run without displaying any IE instance or steps.</param>
        /// <param name="timeOut">The default time out to use when calling IE.AttachToIE(findby).</param>
        /// <param name="autoCloseIE">If true when a reference to the IE instance is destroyed the actual window will close.</param>
        /// <param name="movePointer">It true the mouse pointer will move to the top left corner of the screen when a new IE instance is created.</param>
        /// <returns>The new IE instance.</returns>
        public static IE OpenIEInstance(string targetURL, bool silentMode, int timeOut, bool autoCloseIE, bool movePointer)
        {
            Settings.MakeNewIeInstanceVisible = !silentMode;
            Settings.WaitForCompleteTimeOut = timeOut;
            Settings.WaitUntilExistsTimeOut = timeOut;
            Settings.AttachToBrowserTimeOut = timeOut;
            Settings.AutoMoveMousePointerToTopLeft = movePointer;

            IE ieInstance = new IE { AutoClose = autoCloseIE };
            if(!silentMode) ieInstance.ShowWindow(NativeMethods.WindowShowStyle.ShowMaximized);
            ieInstance.BringToFront();
            ieInstance.GoTo(targetURL);

            return ieInstance;
        }
        public void Adding_Items_ToCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                Assert.IsTrue(browser.ContainsText("8.99"));
            }
        }
        public void SimpleJavaAlertHandler()
        {
            WatiN.Core.Settings.AutoMoveMousePointerToTopLeft = false;
            WatiN.Core.Settings.MakeNewIeInstanceVisible = true;

            using(WatiN.Core.IE ie = new IE(Path.Combine(System.Environment.CurrentDirectory, "testpage1.htm")))
            {
                ie.BringToFront();
                Assert.AreEqual("Alert test", ie.Link("linkAlert").Text);

                WatiN.Core.DialogHandlers.SimpleJavaDialogHandler handler = new SimpleJavaDialogHandler();
                ie.DialogWatcher.Add(handler);

                ie.Link("linkAlert").Click();

                Assert.AreEqual("This is an alert message", handler.Message);
            }
        }
        public void ConfirmJavaDialogHandler()
        {
            WatiN.Core.Settings.AutoMoveMousePointerToTopLeft = false;
            WatiN.Core.Settings.MakeNewIeInstanceVisible = true;

            using (WatiN.Core.IE ie = new IE(Path.Combine(System.Environment.CurrentDirectory, "testpage1.htm")))
            {
                ie.BringToFront();
                WatiN.Core.DialogHandlers.ConfirmDialogHandler handler = new ConfirmDialogHandler();
                ie.DialogWatcher.Add(handler);

                ie.Link("linkConfirm").ClickNoWait();
                handler.WaitUntilExists(2000);

                Assert.AreEqual("Continue", handler.Message);

                handler.OKButton.Click();

            }
        }
        public void RemoveItemsFromCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                browser.Link(Find.BySelector("a.RemoveLink")).Click();

                Assert.IsTrue(browser.ContainsText("0"));

            }
        }
        public void Login_Successful_Should_Have_LogOut_Link()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                //browser.Element(x => x.)

                browser.TextField(Find.ById("UserName")).TypeText("administrator");

                browser.TextField(Find.ById("Password")).TypeText("password123!");

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.Link(Find.ByText("Log Out")).Exists);

                browser.Link(Find.ByText("Log Out")).Click();

            }
        }
        public void Login_UnSuccessful_Should_Have_Error()
        {
            var browser = new IE();

                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.TextField(Find.ById("UserName")).TypeText("admin");

                browser.TextField(Find.ById("Password")).TypeText("1234");

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("Login was unsuccessful."));
        }
        public void Login_WithoutUsernameAndPassword_Should_Have_ErrorMessage()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("The User name field is required"));

                Assert.IsTrue(browser.ContainsText("The Password field is required."));
            }
        }
Example #11
0
        public Result LaunchPageInBrowser(string Url)
        {
            try
            {
                browser = new IE(Url);

                browser.WaitForComplete();
            }
            catch (Exception e)
            {
                Console.WriteLine("BaseFixture.LaunchPageInBrowser: " + e.ToString());

                Thread.Sleep(500);

                browser = new IE(Url);

                browser.WaitForComplete();
            }

            browser.BringToFront();

            browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);

            return Result.CreatePass();
        }