Inheritance: Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
 /// <summary>
 /// Initializes a new instance of the InternetExplorerWebElementCollection class
 /// </summary>
 /// <param name="driver">driver in use</param>
 /// <param name="elements">Elements on the page</param>
 public InternetExplorerWebElementCollection(InternetExplorerDriver driver, SafeWebElementCollectionHandle elements)
 {
     this.driver      = driver;
     collectionHandle = elements;
 }
 /// <summary>
 /// Initializes a new instance of the InternetExplorerWebElementCollection class
 /// </summary>
 /// <param name="driver">driver in use</param>
 /// <param name="elements">Elements on the page</param>
 public InternetExplorerWebElementCollection(InternetExplorerDriver driver, SafeWebElementCollectionHandle elements)
 {
     this.driver = driver;
     collectionHandle = elements;
 }
Exemplo n.º 5
0
 internal static extern WebDriverResult wdcGetElementAtIndex(SafeWebElementCollectionHandle elementCollection, int index, ref SafeInternetExplorerWebElementHandle result);
Exemplo n.º 6
0
 internal static extern WebDriverResult wdcGetElementCollectionLength(SafeWebElementCollectionHandle elementCollection, ref int count);
Exemplo n.º 7
0
 internal static extern WebDriverResult wdFindElementsByXPath(SafeInternetExplorerDriverHandle driver, SafeInternetExplorerWebElementHandle element, [MarshalAs(UnmanagedType.LPWStr)] string xpath, ref SafeWebElementCollectionHandle result);
Exemplo n.º 8
0
 /// <summary>
 /// Gets the length of an element collection.
 /// </summary>
 /// <param name="elementCollectionHandle">A handle to the web element collection.</param>
 /// <param name="count">The number of items in the collection.</param>
 /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns>
 internal WebDriverResult GetElementCollectionLength(SafeWebElementCollectionHandle elementCollectionHandle, ref int count)
 {
     IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, GetElementCollectionLengthFunctionName);
     GetElementCollectionLengthFunction elementCollectionLengthFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(GetElementCollectionLengthFunction)) as GetElementCollectionLengthFunction;
     WebDriverResult result = elementCollectionLengthFunction(elementCollectionHandle, ref count);
     return result;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Gets an item from an element collection.
 /// </summary>
 /// <param name="elementCollectionHandle">A handle to the web element collection.</param>
 /// <param name="index">The index of the item the collection.</param>
 /// <param name="elementHandle">A handle to the instance of the <see cref="InternetExplorerWebElement"/> class.</param>
 /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns>
 internal WebDriverResult GetElementAtIndex(SafeWebElementCollectionHandle elementCollectionHandle, int index, ref SafeInternetExplorerWebElementHandle elementHandle)
 {
     IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, GetElementAtIndexFunctionName);
     GetElementAtIndexFunction elementCollectionItemFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(GetElementAtIndexFunction)) as GetElementAtIndexFunction;
     WebDriverResult result = elementCollectionItemFunction(elementCollectionHandle, index, ref elementHandle);
     return result;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Finds all elements on the page meeting the specified criteria.
 /// </summary>
 /// <param name="driverHandle">A handle to the instance of the <see cref="InternetExplorerDriver"/> class.</param>
 /// <param name="elementHandle">A handle to the instance of the <see cref="InternetExplorerWebElement"/> class.</param>
 /// <param name="xpath">The criteria to use to find the elements.</param>
 /// <param name="foundElementCollectionHandle">A handle to the collection containing found elements.</param>
 /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns>
 internal WebDriverResult FindElementsByXPath(SafeInternetExplorerDriverHandle driverHandle, SafeInternetExplorerWebElementHandle elementHandle, string xpath, ref SafeWebElementCollectionHandle foundElementCollectionHandle)
 {
     IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, FindElementsByXPathFunctionName);
     ElementCollectionFindingFunction findElementsFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(ElementCollectionFindingFunction)) as ElementCollectionFindingFunction;
     WebDriverResult result = findElementsFunction(driverHandle, elementHandle, xpath, ref foundElementCollectionHandle);
     return result;
 }
Exemplo n.º 11
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);
        }