Exemplo n.º 1
0
        public void WhenCallingFindAfter_IfRootIsThePage_ShouldReturnElement()
        {
            string html = @"
                <html id='control1'>
                    <input id='control2' type='button' /> 
                    <span id='something'>
                        <a id='CURRENT' href='foo' />
                    </span>
                    <span id='TARGET'/>
                    <select id='control4' value='bar' />
                    <select id='control5' value='bar' />
                </html>
                ";

            HtmlElement root    = HtmlElement.Create(html);
            var         current = root.ChildElements.Find("CURRENT");

            HtmlElementCollection pageCollection = new HtmlElementCollection(root.ChildElements, root.ParentPage, null);

            Assert.AreEqual("TARGET", pageCollection.FindAfter(current, "TARGET").Id);
        }
Exemplo n.º 2
0
        public void WhenCallingFindAfter_IfCannotFindElementAndRootIsThePage_ShouldThrowError()
        {
            //Arrange
            string html = @"
                <html id='control1'>
                    <input id='control2' type='button' /> 
                    <span id='something'>
                        <a id='CURRENT' href='foo' />
                    </span>
                    <span id='something'/>
                    <select id='control4' value='bar' />
                    <select id='control5' value='bar' />
                </html>
                ";

            HtmlElement root    = HtmlElement.Create(html);
            var         current = root.ChildElements.Find("CURRENT");

            HtmlElementCollection pageCollection = new HtmlElementCollection(root.ChildElements, root.ParentPage, null);

            //Act,Assert
            ExceptionAssert.ThrowsElementNotFound(
                () => pageCollection.FindAfter(current, "TARGET"));
        }