Example #1
0
    public void PopupPageWithIndex()
    {
        // This test also shows the use of the WebTestConsole to add traces to the driver page

        // Navigate to the frameset
        HtmlPage page = new HtmlPage("TestFrameSet.htm");

        //get the top frame
        WebTestConsole.Write("Get the top frame");
        HtmlPage frame = page.GetFramePage("topFrame");

        // click on the button that opens a new page
        WebTestConsole.Write("Click the openwindow button");
        frame.Elements.Find("OpenWindow").Click();

        // get popup window
        WebTestConsole.Write("Get the popup page");
        HtmlPage popup = frame.GetPopupPage(1);

        // verify title of popup
        Assert.AreEqual("This is the Popup Page", popup.Elements.Find("h1", 0).GetInnerText());

        // click on a button in popup window
        WebTestConsole.Write("Click on button inside popup");
        popup.Elements.Find("ChangeSpanButton").Click();
        Assert.AreEqual("Button has been clicked", popup.Elements.Find("TheSpan").GetInnerText());

        //close the popup window
        WebTestConsole.Write("Click the button to close the popup");
        popup.Elements.Find("CloseWindowButton").Click();
    }
Example #2
0
        public void GetFrame_ThrowsIfFailsToRefresh()
        {
            MockCommandExecutor commandExec = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);
            _newWindowRefreshCount        = 0;
            commandExec.ExecutingCommand += new EventHandler(commandExec_ExecutingCommandThrows);

            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("http://test");
            var testPage = new HtmlPage();

            testPage.GetFramePage(new string[] { "foo" }, 0);
        }
Example #3
0
    public void Frame()
    {
        HtmlPage page = new HtmlPage("TestFrameSet.htm");

        // get top frame
        HtmlPage frame = page.GetFramePage("topFrame");

        // verify title of frame
        Assert.AreEqual("This is the top frame", frame.Elements.Find("h1", 0).GetInnerText());

        // click on a button in frame
        frame.Elements.Find("ChangeSpanButton").Click();
        Assert.AreEqual("Button has been clicked", frame.Elements.Find("TheSpan").GetInnerText());
    }
Example #4
0
    public void PageWithIFrame()
    {
        HtmlPage page = new HtmlPage("TestFrameSet.htm");

        // get bottom frame
        HtmlPage bottomFrame = page.GetFramePage("bottomFrame");

        // verify title of frame
        Assert.AreEqual("This is the bottom frame with an iFrame", bottomFrame.Elements.Find("h1", 0).GetInnerText());

        // get the iFrame
        HtmlPage iFrame = bottomFrame.GetFramePage("theIFrame");

        //click on a button in frame
        iFrame.Elements.Find("ChangeSpanButton").Click();
        Assert.AreEqual("Button has been clicked", iFrame.Elements.Find("TheSpan").GetInnerText());
    }
Example #5
0
        public void GetFrame_NestedFrames()
        {
            MockCommandExecutor commandExec = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);
            commandExec.SetBrowserInfo(new BrowserInfo()
            {
                Data = "<html><body><input id='Button1' /></body></html>"
            });
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("http://test");
            var testPage = new HtmlPage();

            HtmlPage framePage = testPage.GetFramePage("frame1", "frame2", "frame3");

            framePage.Elements.Find("Button1").Click();
            UnitTestAssert.AreEqual("Click (Frame: frame1-frame2-frame3)", commandExec.ExecutedCommands[1].Description);
            UnitTestAssert.AreEqual("frame1", (string)commandExec.ExecutedCommands[1].Target.FrameHierarchy[0]);
            UnitTestAssert.AreEqual("frame2", (string)commandExec.ExecutedCommands[1].Target.FrameHierarchy[1]);
            UnitTestAssert.AreEqual("frame3", (string)commandExec.ExecutedCommands[1].Target.FrameHierarchy[2]);
        }
Example #6
0
        public void GetFrame_ActionsFromFrameGetSentWithCorrectFrameHierarchy()
        {
            MockCommandExecutor commandExec = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);
            commandExec.SetBrowserInfo(new BrowserInfo()
            {
                Data = "<html><body><input id='Button1' /></body></html>"
            });
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("http://test");
            var testPage = new HtmlPage();

            HtmlPage framePage = testPage.GetFramePage("FrameName");

            framePage.Elements.Find("Button1").Click();

            UnitTestAssert.AreEqual("ClickElement", commandExec.ExecutedCommands[1].Handler.ClientFunctionName);
            UnitTestAssert.AreEqual("Click (Frame: FrameName)", commandExec.ExecutedCommands[1].Description);
            UnitTestAssert.AreEqual("FrameName", (string)commandExec.ExecutedCommands[1].Target.FrameHierarchy[0]);
        }
Example #7
0
        public void GetFrame_KeepsTryingUntilRefreshSucceeds()
        {
            MockCommandExecutor commandExec = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);
            commandExec.SetBrowserInfo(new BrowserInfo()
            {
                Data = "<html><body>Hello</body></html>"
            });
            _newWindowRefreshCount        = 0;
            commandExec.ExecutingCommand += new EventHandler(commandExec_ExecutingCommandThrows);

            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("http://test");
            var testPage = new HtmlPage();

            HtmlPage framePage = testPage.GetFramePage(new string[] { "foo" }, timeoutInSeconds: 1, waitBetweenAttemptsInMilliseconds: 0);

            UnitTestAssert.IsNotNull(framePage);
            Assert.AreEqual(_newWindowRefreshCount, 2);
        }