protected ArrayList DoFilter(Attribute findBy) { ArrayList returnElements; if (elements == null) { if (finder != null) { returnElements = finder.FindAll(findBy); } else { returnElements = new ArrayList(); } } else { returnElements = new ArrayList(); ElementAttributeBag attributeBag = new ElementAttributeBag(); foreach (IHTMLElement element in Elements) { attributeBag.IHTMLElement = element; if (findBy.Compare(attributeBag)) { returnElements.Add(element); } } } return(returnElements); }
private ArrayList findElementsByAttribute(ElementTag elementTag, Attribute findBy, bool returnAfterFirstMatch) { // Get elements with the tagname from the page ArrayList children = new ArrayList(); IHTMLElementCollection elements = elementTag.GetElementCollection(elementCollection.Elements); if (elements != null) { ElementAttributeBag attributeBag = new ElementAttributeBag(); // Loop through each element and evaluate foreach (IHTMLElement element in elements) { // waitUntilElementReadyStateIsComplete(element); attributeBag.IHTMLElement = element; if (elementTag.Compare(element) && findBy.Compare(attributeBag)) { children.Add(element); if (returnAfterFirstMatch) { return(children); } } } } return(children); }
public bool Exists(Attribute findBy) { ElementAttributeBag attributeBag = new ElementAttributeBag(); foreach (IHTMLElement element in Elements) { attributeBag.IHTMLElement = element; if (findBy.Compare(attributeBag)) { return(true); } } return(false); }
/// <summary> /// Waits until the given <paramref name="attribute" /> matches. /// </summary> /// <param name="attribute">The attribute.</param> /// <param name="timeout">The timeout.</param> public void WaitUntil(Attribute attribute, int timeout) { Exception lastException; ElementAttributeBag attributeBag = new ElementAttributeBag(); SimpleTimer timeoutTimer = new SimpleTimer(timeout); do { lastException = null; try { // Calling Exists will refresh the reference to the html element // so the compare is against the current html element (and not // against some cached reference. if (Exists) { attributeBag.IHTMLElement = htmlElement; if (attribute.Compare(attributeBag)) { return; } } } catch (Exception e) { lastException = e; } Thread.Sleep(200); } while (!timeoutTimer.Elapsed); ThrowTimeOutException(lastException, string.Format("waiting {0} seconds for element attribute '{1}' to change to '{2}'.", timeout, attribute.AttributeName, attribute.Value)); }
protected ArrayList DoFilter(Attribute findBy) { ArrayList returnElements; if (elements == null) { if (finder != null) { returnElements = finder.FindAll(findBy); } else { returnElements = new ArrayList(); } } else { returnElements = new ArrayList(); ElementAttributeBag attributeBag = new ElementAttributeBag(); foreach (IHTMLElement element in Elements) { attributeBag.IHTMLElement = element; if (findBy.Compare(attributeBag)) { returnElements.Add(element); } } } return returnElements; }
public bool Exists(Attribute findBy) { ElementAttributeBag attributeBag = new ElementAttributeBag(); foreach (IHTMLElement element in Elements) { attributeBag.IHTMLElement = element; if (findBy.Compare(attributeBag)) { return true; } } return false; }
private ArrayList findElementsByAttribute(ElementTag elementTag, Attribute findBy, bool returnAfterFirstMatch) { // Get elements with the tagname from the page ArrayList children = new ArrayList(); IHTMLElementCollection elements = elementTag.GetElementCollection(elementCollection.Elements); if (elements != null) { ElementAttributeBag attributeBag = new ElementAttributeBag(); // Loop through each element and evaluate foreach (IHTMLElement element in elements) { // waitUntilElementReadyStateIsComplete(element); attributeBag.IHTMLElement = element; if (elementTag.Compare(element) && findBy.Compare(attributeBag)) { children.Add(element); if (returnAfterFirstMatch) { return children; } } } } return children; }