Пример #1
0
        public void TableIsRefreshedThenTBodyIsRefreshed()
        {
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);
            var testPage = new HtmlPage();

            string html = @"
                <html id='control1'>
                    <table id='MyTable'> 
                        <tbody>
                            <tr>First</tr>
                            <tr>Second</tr>
                        </tbody>
                    </table>
                </html>
                ";

            HtmlElement      element = HtmlElement.Create(html, testPage, false);
            HtmlTableElement table   = (HtmlTableElement)element.ChildElements.Find("MyTable");

            commandExecutor.SetBrowserInfo(new LTAF.Engine.BrowserInfo()
            {
                Data = @"<table id='MyTable'>
                            <tbody>
                                <tr>First Refreshed</tr>
                                <tr>Second Refreshed</tr>
                            </tbody>
                        </table>"
            });

            table.ChildElements.Refresh();
            UnitTestAssert.AreEqual(2, table.Rows.Count);
            UnitTestAssert.AreEqual("First Refreshed", table.Rows[0].CachedInnerText);
            UnitTestAssert.AreEqual("Second Refreshed", table.Rows[1].CachedInnerText);

            commandExecutor.SetBrowserInfo(new LTAF.Engine.BrowserInfo()
            {
                Data = @"<tbody>
                                <tr>First Refreshed again</tr>
                                <tr>Second Refreshed again</tr>
                                <tr>Third Refreshed again</tr>
                            </tbody>"
            });

            table.TBody.ChildElements.Refresh();
            UnitTestAssert.AreEqual(3, table.Rows.Count);
            UnitTestAssert.AreEqual("First Refreshed again", table.Rows[0].CachedInnerText);
            UnitTestAssert.AreEqual("Second Refreshed again", table.Rows[1].CachedInnerText);
            UnitTestAssert.AreEqual("Third Refreshed again", table.Rows[2].CachedInnerText);
        }
Пример #2
0
        public void ClickPopupActionGetTextBack()
        {
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);
            var         testPage = new HtmlPage();
            HtmlElement element  = new HtmlElement("input",
                                                   new Dictionary <string, string>()
            {
                { "id", "button1" }, { "type", "button" }
            },
                                                   null,
                                                   testPage);

            CommandParameters commandParameters = new CommandParameters(WaitFor.None, PopupAction.ConfirmOK);

            commandExecutor.SetBrowserInfo(new BrowserInfo()
            {
                Data = "This is the text from confirm"
            });

            element.Click(commandParameters);

            UnitTestAssert.AreEqual(PopupAction.ConfirmOK, commandExecutor.ExecutedCommands[0].Handler.PopupAction);
            UnitTestAssert.AreEqual("This is the text from confirm", commandParameters.PopupText);
        }
Пример #3
0
        public void WhenRefreshing_IfPassingTwoAttribute_ShouldRefreshDomIncludingThoseAttributes()
        {
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);
            var testPage = new HtmlPage();

            string html = @"
                <html id='control1'>
                    <span id='MySpan' randomAttribute='foo'>
                        Span text
                    </span> 
                </html>
                ";

            commandExecutor.SetBrowserInfo(new LTAF.Engine.BrowserInfo()
            {
                Data = @"<span id='MySpan' randomAttribute='bar'>
                        Span text
                        </span>"
            });

            var element = HtmlElement.Create(html, testPage, false);
            var span    = element.ChildElements.Find("MySpan");

            span.ChildElements.Refresh(new string[] { "randomAttribute", "anotherAttribute" });
            Assert.AreEqual("randomattribute-anotherattribute", commandExecutor.ExecutedCommands[0].Handler.Arguments[0]);
        }
Пример #4
0
        public void WhenRefreshing_ShouldNotGetGetAttributes()
        {
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);
            var testPage = new HtmlPage();

            string html = @"
                <html id='control1'>
                    <span id='MySpan' randomAttribute='foo'>
                        Span text
                    </span> 
                </html>
                ";

            commandExecutor.SetBrowserInfo(new LTAF.Engine.BrowserInfo()
            {
                Data = @"<span id='MySpan' randomAttribute='bar'>
                        Span text
                        </span>"
            });

            var element = HtmlElement.Create(html, testPage, false);
            var span    = element.ChildElements.Find("MySpan");

            span.ChildElements.Refresh();
            Assert.IsNull(commandExecutor.ExecutedCommands[0].Handler.Arguments);
        }
Пример #5
0
        public void IsVisible_False()
        {
            MockCommandExecutor commandExec = new MockCommandExecutor();

            commandExec.SetBrowserInfo(new BrowserInfo()
            {
                Data = "<input id='button1' type='button' style='visibility:hidden;' />"
            });
            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);
            var testPage = new HtmlPage();

            HtmlElement element = HtmlElement.Create("<input id='textbox1' type='textbox' />", testPage, false);

            UnitTestAssert.IsFalse(element.IsVisible());

            UnitTestAssert.AreEqual("GetElementAttributes", commandExec.ExecutedCommands[0].Handler.ClientFunctionName);
        }