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); }
public void ChildTagNameGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.IsNull(info.ChildTagName); info.ChildTagName = "foo"; Assert.AreEqual("foo", info.ChildTagName); }
public void IndexGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.AreEqual(0, info.Index); info.Index = 2; Assert.AreEqual(2, info.Index); }
public void IdGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.IsNull(info.Id); info.Id = "foo"; Assert.AreEqual("foo", info.Id); }
public void WindowIndexGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.AreEqual(0, info.WindowIndex); info.WindowIndex = 1; Assert.AreEqual(1, info.WindowIndex); }
public void WindowCaptionGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.IsNull(info.WindowCaption); info.WindowCaption = "foo"; Assert.AreEqual("foo", info.WindowCaption); }
public void TextBetweenTagsGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.IsNull(info.TextBetweenTags); info.TextBetweenTags = "foo"; Assert.AreEqual("foo", info.TextBetweenTags); }
public void FrameHierarchyGetSet() { BrowserCommandTarget info = new BrowserCommandTarget(); Assert.IsNull(info.FrameHierarchy); info.FrameHierarchy = new object[1] { "foo" }; Assert.IsNotNull(info.FrameHierarchy); }
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."); }