public IEElementCollection(IEnumerable htmlElementCollection, IEElement element) { if (htmlElementCollection == null) { throw new ArgumentNullException("htmlElementCollection"); } _htmlElementCollection = htmlElementCollection; _element = element; }
public IEDocument(IHTMLDocument2 htmlDocument, IEElement containingFrameElement) { if (htmlDocument == null) { throw new ArgumentNullException("htmlDocument"); } this.htmlDocument = htmlDocument; this.containingFrameElement = containingFrameElement; }
public void Process(IWebBrowser2 webBrowser2) { // Get the frame element from the parent document var uniqueId = RetrieveUniqueIdOfFrameElement(); var frameElement = RetrieveSameFrameFromHtmlDocument(uniqueId); var nativeFrameElement = new IEElement(frameElement); Elements.Add(new IEDocument((IHTMLDocument2)webBrowser2.Document, nativeFrameElement)); index++; }
private static Rectangle GetTextBoundsByInsertingElement(IHTMLTxtRange textRange, IHTMLDocument2 document) { // A bit of a hack: create an HTML element around the selected // text and get the location of that element from document.all[]. // Note that this is actually pretty common hack for search/highlight functions: // http://www.pcmag.com/article2/0,2704,1166598,00.asp // http://www.codeproject.com/miscctrl/chtmlview_search.asp // http://www.itwriting.com/phorum/read.php?3,1561,1562,quote=1 // Save the text string oldHtmlText = textRange.htmlText; // Sometimes the text range contains the containing HTML element such as a SPAN tag. // eg. "<SPAN id=spanValidateCode>Code and Confirm Code must match!</SPAN>" // // This is ok. We just grab the bounds of the whole element, which happens to be the // one returned by parentElement(). if (oldHtmlText != textRange.text) { return(IEElement.GetHtmlElementBounds(textRange.parentElement())); } // Create a unique ID string id = @"__WatiNTextRange_" + Guid.NewGuid(); // Add a span tag the the HTML string code = String.Format("<span id=\"{0}\">{1}</span>", id, oldHtmlText); textRange.pasteHTML(code); // Get the element's position var element = (IHTMLElement)document.all.item(id, null); // Build the bounds Rectangle bounds = IEElement.GetHtmlElementBounds(element); // Restore the HTML // This only seems to work if the text is not immediately preceded by a span element. // In that case it fails because it seems to grab the parent span element when identifying // the 'outerHTML' and then duplicates that for each pass. element.outerHTML = oldHtmlText; // Doesn't work: Does not replace the text when pasted into place despite suggestions in implementations // listed above //textRange.pasteHTML( oldHtml ); return(bounds); }
public IEFireEventHandler(IEElement ieElement) { _ieElement = ieElement; }