public ActionElementBase(BrowserWindow windowName, IHTMLElement element, string url) : base(windowName) { if (element == null) { return; } ActionFinder = new FindAttributeCollection(element, null, url); AllAttributes = ActionFinder.GetAvailableAttributes(element); ActionFrames = new List <FindAttributeCollection>(); SetFrameList(element); }
private HTMLFrameBase SetFrame(IHTMLDocument2 doc) { if (doc == null) { return(null); } HTMLWindow2 frameCollection; try { frameCollection = doc.frames as HTMLWindow2; if (frameCollection == null) { return(null); } frameCollection = frameCollection.frames as HTMLWindow2; if (frameCollection == null || frameCollection.frameElement == null) { return(null); } } catch (Exception) { return(null); } if (frameCollection.frameElement.GetType().GetInterface("IHTMLFrameElement") == null && frameCollection.frameElement.GetType().GetInterface("IHTMLIFrameElement") == null) { return(null); } if (frameCollection.frameElement == null) { return(null); } var frameElement = (IHTMLElement)frameCollection.frameElement; var actionfinder = new FindAttributeCollection(); actionfinder.ActionUrl = frameCollection.location.toString(); List <FindAttribute> attributes = actionfinder.GetFindAttributes(frameElement); if (attributes.Count > 0) { ActionFrames.Add(actionfinder); } return((HTMLFrameBase)frameElement); }
/// <summary> /// Private method to serialize the find attributes of an action with an element /// </summary> /// <param name="writer">xml writer to write with</param> /// <param name="tagname">tag to find</param> /// <param name="attributeCollection">collection of attributes to serialize</param> private static void SerializeFindAttributes(XmlWriter writer, string tagname, string actionUrl, FindAttributeCollection attributeCollection) { writer.WriteStartElement("FindAttributeCollection"); writer.WriteAttributeString("TagName", tagname); writer.WriteAttributeString("ActionUrl", actionUrl); foreach (FindAttribute findAttribute in attributeCollection.AttributeList) { writer.WriteStartElement("FindAttribute"); writer.WriteAttributeString("FindName", findAttribute.FindName); writer.WriteAttributeString("Regex", findAttribute.Regex ? "1" : "0"); writer.WriteString(System.Web.HttpUtility.HtmlEncode(findAttribute.FindValue)); writer.WriteEndElement(); } writer.WriteEndElement(); }