Collection of Elements from Internet Explorer
Наследование: IDisposable
Пример #1
0
        /// <summary>
        /// Finds a list of elements that match the link text supplied
        /// </summary>
        /// <param name="linkText">Link text of element</param>
        /// <returns>ReadOnlyCollection of IWebElement object so that you can interact with those objects</returns>
        public ReadOnlyCollection <IWebElement> FindElementsByLinkText(string linkText)
        {
            SafeWebElementCollectionHandle collectionHandle = new SafeWebElementCollectionHandle();
            WebDriverResult result = NativeDriverLibrary.Instance.FindElementsByLinkText(handle, parent, linkText, ref collectionHandle);

            ResultHandler.VerifyResultCode(result, "FindElementsByLinkText");
            List <IWebElement> elementList = new List <IWebElement>();

            using (InternetExplorerWebElementCollection elements = new InternetExplorerWebElementCollection(driver, collectionHandle))
            {
                elementList = elements.ToList();
            }

            return(new ReadOnlyCollection <IWebElement>(elementList));
        }
Пример #2
0
        /// <summary>
        /// Find all the elements taht match the XPath
        /// </summary>
        /// <param name="xpath">XPath to the element</param>
        /// <returns>ReadOnlyCollection of IWebElement object so that you can interact that object</returns>
        public ReadOnlyCollection<IWebElement> FindElementsByXPath(string xpath)
        {
            SafeWebElementCollectionHandle collectionHandle = new SafeWebElementCollectionHandle();
            WebDriverResult result = NativeDriverLibrary.Instance.FindElementsByXPath(handle, parent, xpath, ref collectionHandle);
            ResultHandler.VerifyResultCode(result, "FindElementsByXPath");
            List<IWebElement> elementList = new List<IWebElement>();
            using (InternetExplorerWebElementCollection elements = new InternetExplorerWebElementCollection(driver, collectionHandle))
            {
                elementList = elements.ToList();
            }

            return new ReadOnlyCollection<IWebElement>(elementList);
        }
Пример #3
0
        /// <summary>
        /// Find all elements that match the tag
        /// </summary>
        /// <param name="tagName">tagName of element on the page</param>
        /// <returns>ReadOnlyCollection of IWebElement object so that you can interact that object</returns>
        public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
        {
            SafeWebElementCollectionHandle collectionHandle = new SafeWebElementCollectionHandle();
            WebDriverResult result = NativeMethods.wdFindElementsByTagName(handle, parent, tagName, ref collectionHandle);
            ResultHandler.VerifyResultCode(result, "FindElementsByTagName");
            List<IWebElement> elementList = new List<IWebElement>();
            using (InternetExplorerWebElementCollection elements = new InternetExplorerWebElementCollection(driver, collectionHandle))
            {
                elementList = elements.ToList();
            }

            return new ReadOnlyCollection<IWebElement>(elementList);
        }