示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        /// <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;
        }
示例#8
0
        /// <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));
        }