コード例 #1
0
        public override bool Compare(IAttributeBag attributeBag)
        {
            ElementAttributeBag elementAttributeBag = (ElementAttributeBag)attributeBag;
            IHTMLElement        element             = elementAttributeBag.IHTMLElement;

            if (IsTextContainedIn(element.innerText))
            {
                // Get all elements and filter this for TableCells
                IHTMLTableRow          tableRowElement   = (IHTMLTableRow)element;
                IHTMLElementCollection tableCellElements = tableRowElement.cells;

                if (tableCellElements.length - 1 >= columnIndex)
                {
                    IHTMLTableCell  tableCell       = (IHTMLTableCell)tableCellElements.item(columnIndex, null);
                    ICompareElement elementComparer = comparer as ICompareElement;

                    if (elementComparer != null)
                    {
                        return(elementComparer.Compare(new TableCell(elementAttributeBag.DomContainer, tableCell)));
                    }
                    return(base.Compare(new ElementAttributeBag(elementAttributeBag.DomContainer, (IHTMLElement)tableCell)));
                }
            }

            return(false);
        }
コード例 #2
0
 public IAttributeBag GetAttributeBag(DomContainer domContainer)
 {
     if (_attributeBag == null)
     {
         _attributeBag = new ElementAttributeBag(domContainer);
     }
     _attributeBag.IHTMLElement = htmlElement;
     return(_attributeBag);
 }
コード例 #3
0
        private ArrayList findElementsByAttribute(ElementTag elementTag, BaseConstraint constraint, bool returnAfterFirstMatch)
        {
            // Get elements with the tagname from the page
            constraint.Reset();
            ElementAttributeBag attributeBag = new ElementAttributeBag(_domContainer);

            if (FindByExactMatchOnIdPossible(constraint))
            {
                return(FindElementById(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection));
            }
            return(FindElements(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection));
        }
コード例 #4
0
        protected override bool DoCompare(IAttributeBag attributeBag)
        {
            Element element = null;

            ElementAttributeBag elementAttributeBag = attributeBag as ElementAttributeBag;

            if (elementAttributeBag != null)
            {
                element = elementAttributeBag.ElementTyped;
            }

            if (element == null)
            {
                element = attributeBag as Element;
            }

            if (element != null)
            {
                return(EvaluateAndOrAttributes(attributeBag, _comparer.Compare(element)));
            }

            throw new Exceptions.WatiNException("This constraint class can only be used to compare against an element");
        }
コード例 #5
0
ファイル: IEElementFinder.cs プロジェクト: pusp/o2platform
	    private static bool FinishedAddingChildrenThatMetTheConstraints(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IHTMLElement element, ref ArrayList children)
	    {            
	        waitUntilElementReadyStateIsComplete(element);

	        attributeBag.IHTMLElement = element;

	        bool validElementType = true;
            if (elementTag.IsInputElement)
            {
                validElementType = elementTag.CompareInputTypes(new IEElement(element));
            }

	        if (validElementType && constraint.Compare(attributeBag))
	        {
	            children.Add(element);
	            if (returnAfterFirstMatch)
	            {
	                return true;
	            }
	        }
	        return false;
	    }
コード例 #6
0
ファイル: IEElementFinder.cs プロジェクト: pusp/o2platform
        private static ArrayList FindElementById(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
	    {
            ArrayList children = new ArrayList();

	        IHTMLElement element = elementTag.GetElementById(elementCollection.Elements, ((AttributeConstraint)constraint).Value);

	        if (element != null)
	        {
	            FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children);
	        }
	        return children;
	    }
コード例 #7
0
ファイル: IEElementFinder.cs プロジェクト: pusp/o2platform
	    public static ArrayList FindElements(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
	    {
	        IHTMLElementCollection elements = elementTag.GetElementCollection(elementCollection.Elements);
            ArrayList children = new ArrayList();

	        if (elements != null)
	        {
	            // Loop through each element and evaluate
	            int length = elements.length;
	            for (int index = 0; index < length; index++ )
                {
                    IHTMLElement element = (IHTMLElement)elements.item(index, null);
                    if (FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children))
                    {
                        return children;
                    }
                }
	        }

	        return children;
	    }
コード例 #8
0
ファイル: IEElementFinder.cs プロジェクト: pusp/o2platform
		private ArrayList findElementsByAttribute(ElementTag elementTag, BaseConstraint constraint, bool returnAfterFirstMatch)
		{
			// Get elements with the tagname from the page
		    constraint.Reset();
            ElementAttributeBag attributeBag = new ElementAttributeBag(_domContainer);

            if (FindByExactMatchOnIdPossible(constraint))
            {
                return FindElementById(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection);
            }
            return FindElements(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection);
		}
コード例 #9
0
ファイル: IEElement.cs プロジェクト: pusp/o2platform
	    public IAttributeBag GetAttributeBag(DomContainer domContainer)
	    {
	        if (_attributeBag == null)
	        {
	            _attributeBag = new ElementAttributeBag(domContainer);
	        }
	        _attributeBag.IHTMLElement = htmlElement;
	        return _attributeBag;
	    }
コード例 #10
0
        private static bool FinishedAddingChildrenThatMetTheConstraints(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IHTMLElement element, ref ArrayList children)
        {
            waitUntilElementReadyStateIsComplete(element);

            attributeBag.IHTMLElement = element;

            bool validElementType = true;

            if (elementTag.IsInputElement)
            {
                validElementType = elementTag.CompareInputTypes(new IEElement(element));
            }

            if (validElementType && constraint.Compare(attributeBag))
            {
                children.Add(element);
                if (returnAfterFirstMatch)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #11
0
        private static ArrayList FindElementById(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
        {
            ArrayList children = new ArrayList();

            IHTMLElement element = elementTag.GetElementById(elementCollection.Elements, ((AttributeConstraint)constraint).Value);

            if (element != null)
            {
                FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children);
            }
            return(children);
        }
コード例 #12
0
        public static ArrayList FindElements(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
        {
            IHTMLElementCollection elements = elementTag.GetElementCollection(elementCollection.Elements);
            ArrayList children = new ArrayList();

            if (elements != null)
            {
                // Loop through each element and evaluate
                int length = elements.length;
                for (int index = 0; index < length; index++)
                {
                    IHTMLElement element = (IHTMLElement)elements.item(index, null);
                    if (FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children))
                    {
                        return(children);
                    }
                }
            }

            return(children);
        }