Exemplo n.º 1
0
        public void BuildTargetLocator2()
        {
            string html = @"
                <html>
                    <table id='GridView1'>
                        <a />
                        <foo>
                            <a />
                            <a />
                        </foo>
                        <a />
                        <bar>
                            <a />
                        </bar>
                    </table>
                </html>
                ";

            HtmlElement element = HtmlElement.Create(html, new HtmlPage(), true);

            element.CanUseTagIndexToLocate = true;

            HtmlElement          child  = element.ChildElements[0].ChildElements[3].ChildElements[0];
            BrowserCommandTarget target = child.BuildBrowserCommandTarget();

            UnitTestAssert.AreEqual("GridView1", target.Id);
            UnitTestAssert.AreEqual("a", target.ChildTagName);
            UnitTestAssert.AreEqual(4, target.ChildTagIndex);
        }
Exemplo n.º 2
0
        public void ChildTagNameGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.IsNull(info.ChildTagName);

            info.ChildTagName = "foo";
            Assert.AreEqual("foo", info.ChildTagName);
        }
Exemplo n.º 3
0
        public void IndexGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.AreEqual(0, info.Index);

            info.Index = 2;
            Assert.AreEqual(2, info.Index);
        }
Exemplo n.º 4
0
        public void IdGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.IsNull(info.Id);

            info.Id = "foo";
            Assert.AreEqual("foo", info.Id);
        }
Exemplo n.º 5
0
        public void WindowIndexGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.AreEqual(0, info.WindowIndex);

            info.WindowIndex = 1;
            Assert.AreEqual(1, info.WindowIndex);
        }
Exemplo n.º 6
0
        public void WindowCaptionGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.IsNull(info.WindowCaption);

            info.WindowCaption = "foo";
            Assert.AreEqual("foo", info.WindowCaption);
        }
Exemplo n.º 7
0
        public void TextBetweenTagsGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.IsNull(info.TextBetweenTags);

            info.TextBetweenTags = "foo";
            Assert.AreEqual("foo", info.TextBetweenTags);
        }
Exemplo n.º 8
0
        public void FrameHierarchyGetSet()
        {
            BrowserCommandTarget info = new BrowserCommandTarget();

            Assert.IsNull(info.FrameHierarchy);

            info.FrameHierarchy = new object[1] {
                "foo"
            };
            Assert.IsNotNull(info.FrameHierarchy);
        }
Exemplo n.º 9
0
        internal BrowserCommandTarget BuildBrowserCommandTarget()
        {
            BrowserCommandTarget commandTarget = new BrowserCommandTarget();

            if (!String.IsNullOrEmpty(this.Id))
            {
                commandTarget.Id = this.Id;
                return(commandTarget);
            }
            else if (!String.IsNullOrEmpty(this.Name))
            {
                commandTarget.Id = this.Name;
                return(commandTarget);
            }
            else if (this._canUseTagIndexToLocate)
            {
                commandTarget.TagName = this.TagName;
                commandTarget.Index   = this.TagNameIndex;
                return(commandTarget);
            }

            HtmlElement nearestParent = FindNearestLocalizableElement();

            commandTarget = nearestParent.BuildBrowserCommandTarget();

            int occurrence;

            if (FindElementOccurrenceFromParent(nearestParent, out occurrence))
            {
                commandTarget.ChildTagName  = this.TagName;
                commandTarget.ChildTagIndex = occurrence - 1;
                return(commandTarget);
            }

            throw new WebTestException("Could not build a command that locates this element.");
        }