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); }
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) { foreach (PopupDialog popupDialog in popupDialogs) { if (findBy.Compare(popupDialog)) { return(true); } } return(false); }
public bool Exists(Attribute findBy) { foreach (Frame frame in elements) { if (findBy.Compare(frame)) { // Return return(true); } } return(false); }
public bool Exists(Attribute findBy) { foreach (Frame frame in elements) { if (findBy.Compare(frame)) { // Return return true; } } return false; }
private static Frame findFrame(FrameCollection frames, Attribute findBy) { foreach (Frame frame in frames) { if (findBy.Compare(frame)) { // Return return(frame); } } throw new FrameNotFoundException(findBy.AttributeName, findBy.Value); }
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> /// Evaluates the and or attributes. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <param name="initialReturnValue">if set to <c>false</c> it will skip the And evaluation.</param> /// <returns></returns> protected bool EvaluateAndOrAttributes(IAttributeBag attributeBag, bool initialReturnValue) { bool returnValue = initialReturnValue; if (returnValue && andAttribute != null) { returnValue = andAttribute.Compare(attributeBag); } if (returnValue == false && orAttribute != null) { returnValue = orAttribute.Compare(attributeBag); } return(returnValue); }
public override bool Compare(IAttributeBag attributeBag) { bool result; LockCompare(); try { result = !(attribute.Compare(attributeBag)); } finally { UnLockCompare(); } return(result); }
/// <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)); }
/// <summary> /// Finds the popup dialog. /// </summary> /// <param name="findBy">The find by.</param> /// <param name="timeout">The timeout.</param> /// <returns></returns> private PopupDialog findPopupDialog(Attribute findBy, int timeout) { Logger.LogAction("Busy finding PopupDialog with " + findBy.AttributeName + " '" + findBy.Value + "'"); SimpleTimer timeoutTimer = new SimpleTimer(timeout); do { Thread.Sleep(500); foreach (PopupDialog popupDialog in PopupDialogs) { if (findBy.Compare(popupDialog)) { return popupDialog; } } } while (!timeoutTimer.Elapsed); throw new PopupDialogNotFoundException(findBy.AttributeName, findBy.Value, timeout); }
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; }
public bool Exists(Attribute findBy) { foreach (PopupDialog popupDialog in popupDialogs) { if (findBy.Compare(popupDialog)) { return true; } } return false; }
private static Frame findFrame(FrameCollection frames, Attribute findBy) { foreach (Frame frame in frames) { if (findBy.Compare(frame)) { // Return return frame; } } throw new FrameNotFoundException(findBy.AttributeName, findBy.Value); }