/// <summary> /// Initializes a new instance of the InternetExplorerDriver class. /// </summary> public InternetExplorerDriver() { handle = new SafeInternetExplorerDriverHandle(); WebDriverResult result = NativeDriverLibrary.Instance.NewDriverInstance(ref handle); if (result != WebDriverResult.Success) { throw new WebDriverException(string.Format(CultureInfo.InvariantCulture, "Cannot create new browser instance: {0}", result.ToString())); } }
/// <summary> /// Initializes a new instance of the Finder class. /// </summary> /// <param name="driver">InternetExplorerDriver in use</param> /// <param name="parent">ElementHandle to for use with the Native methods</param> public Finder(InternetExplorerDriver driver, SafeInternetExplorerWebElementHandle parent) { this.driver = driver; if (parent != null) { this.parent = parent; } else { this.parent = new SafeInternetExplorerWebElementHandle(); } handle = driver.GetUnderlayingHandle(); }
/// <summary> /// If this current element is a form, or an element within a form, then this will be submitted to the remote server. If this causes the current page to change, then this method will block until the new page is loaded. /// </summary> /// <param name="attributeName">Attribute you wish to get details of.</param> /// <returns>The attribute's current value or null if the value is not set.</returns> public string GetAttribute(string attributeName) { SafeStringWrapperHandle stringHandle = new SafeStringWrapperHandle(); SafeInternetExplorerDriverHandle driverHandle = driver.GetUnderlayingHandle(); WebDriverResult result = NativeDriverLibrary.Instance.GetElementAttribute(driverHandle, elementHandle, attributeName, ref stringHandle); ResultHandler.VerifyResultCode(result, string.Format(CultureInfo.InvariantCulture, "getting attribute '{0}' of the element", attributeName)); string returnValue = null; using (StringWrapper wrapper = new StringWrapper(stringHandle)) { returnValue = wrapper.Value; } return(returnValue); }
/// <summary> /// Gets an attribute of the specified element. /// </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="attributeName">The name of the attribute.</param> /// <param name="attributeValueWrapperHandle">A pointer to a string containing the attribute value.</param> /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns> internal WebDriverResult GetElementAttribute(SafeInternetExplorerDriverHandle driverHandle, SafeInternetExplorerWebElementHandle elementHandle, string attributeName, ref SafeStringWrapperHandle attributeValueWrapperHandle) { IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, GetElementAttributeFunctionName); GetElementAttributeFunction getAttributeFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(GetElementAttributeFunction)) as GetElementAttributeFunction; WebDriverResult result = getAttributeFunction(driverHandle, elementHandle, attributeName, ref attributeValueWrapperHandle); return result; }
internal static extern WebDriverResult wdeGetAttribute(SafeInternetExplorerDriverHandle driver, SafeInternetExplorerWebElementHandle wrapper, [MarshalAs(UnmanagedType.LPWStr)] string attributeName, ref SafeStringWrapperHandle result);
internal static extern WebDriverResult wdCaptureScreenshotAsBase64(SafeInternetExplorerDriverHandle driver, out SafeStringWrapperHandle handle);
internal static extern WebDriverResult wdSwitchToWindow(SafeInternetExplorerDriverHandle handle, string windowName);
internal static extern WebDriverResult wdSwitchToActiveElement(SafeInternetExplorerDriverHandle driver, ref SafeInternetExplorerWebElementHandle result);
internal static extern WebDriverResult wdRefresh(SafeInternetExplorerDriverHandle driver);
internal static extern WebDriverResult wdGoForward(SafeInternetExplorerDriverHandle driver);
internal static extern WebDriverResult wdGet(SafeInternetExplorerDriverHandle handle, string url);
internal static extern WebDriverResult wdFindElementsByXPath(SafeInternetExplorerDriverHandle driver, SafeInternetExplorerWebElementHandle element, [MarshalAs(UnmanagedType.LPWStr)] string xpath, ref SafeWebElementCollectionHandle result);
internal static extern WebDriverResult wdFindElementByTagName(SafeInternetExplorerDriverHandle driver, SafeInternetExplorerWebElementHandle element, [MarshalAs(UnmanagedType.LPWStr)] string linkText, ref SafeInternetExplorerWebElementHandle result);
internal static extern WebDriverResult wdExecuteScript(SafeInternetExplorerDriverHandle driver, string script, SafeScriptArgsHandle scriptArgs, ref SafeScriptResultHandle scriptRes);
/// <summary> /// Retrieves the value from the script result. /// </summary> /// <param name="scriptResultHandle">A handle to the result of the script.</param> /// <param name="driverHandle">A handle to the instance of the <see cref="InternetExplorerDriver"/> class.</param> /// <param name="scriptResultValue">A value representing the value of the returned object from the script.</param> /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns> internal WebDriverResult GetElementScriptResult(SafeScriptResultHandle scriptResultHandle, SafeInternetExplorerDriverHandle driverHandle, out SafeInternetExplorerWebElementHandle scriptResultValue) { IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, GetElementScriptResultFunctionName); ElementReturningScriptResultFunction scriptResultFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(ElementReturningScriptResultFunction)) as ElementReturningScriptResultFunction; WebDriverResult result = scriptResultFunction(scriptResultHandle, driverHandle, out scriptResultValue); return result; }
internal static extern WebDriverResult wdGetScriptResultType(SafeInternetExplorerDriverHandle driver, SafeScriptResultHandle scriptResult, out int type);
internal static extern WebDriverResult wdGetTitle(SafeInternetExplorerDriverHandle handle, ref SafeStringWrapperHandle result);
internal static extern WebDriverResult wdGetAllWindowHandles(SafeInternetExplorerDriverHandle driver, ref SafeStringCollectionHandle handles);
internal static extern WebDriverResult wdNewDriverInstance(ref SafeInternetExplorerDriverHandle handle);
internal static extern WebDriverResult wdGetArrayItemFromScriptResult(SafeInternetExplorerDriverHandle driver, SafeScriptResultHandle scriptResult, int itemIndex, out SafeScriptResultHandle item);
internal static extern WebDriverResult wdSetVisible(SafeInternetExplorerDriverHandle handle, int visible);
internal static extern WebDriverResult wdGetArrayLengthScriptResult(SafeInternetExplorerDriverHandle driver, SafeScriptResultHandle scriptResult, out int arrayLength);
internal static extern WebDriverResult wdSwitchToFrame(SafeInternetExplorerDriverHandle handle, string frameName);
internal static extern WebDriverResult wdGetCookies(SafeInternetExplorerDriverHandle handle, ref SafeStringWrapperHandle cookies);
internal static extern WebDriverResult wdWaitForLoadToComplete(SafeInternetExplorerDriverHandle driver);
internal static extern WebDriverResult wdGetCurrentWindowHandle(SafeInternetExplorerDriverHandle driver, out SafeStringWrapperHandle handle);
internal static extern WebDriverResult wdClose(SafeInternetExplorerDriverHandle driver);
/// <summary> /// Initializes a new instance of the Finder class. /// </summary> /// <param name="driver">InternetExplorerDriver in use</param> /// <param name="parent">ElementHandle to for use with the Native methods</param> public Finder(InternetExplorerDriver driver, SafeInternetExplorerWebElementHandle parent) { this.driver = driver; this.parent = parent; handle = driver.GetUnderlayingHandle(); }
internal static extern WebDriverResult wdGetElementScriptResult(SafeScriptResultHandle scriptResult, SafeInternetExplorerDriverHandle driver, out SafeInternetExplorerWebElementHandle value);
/// <summary> /// Gets the identifying handle string of the current window. /// </summary> /// <param name="driverHandle">A handle to the instance of the <see cref="InternetExplorerDriver"/> class.</param> /// <param name="handleWrapperHandle">A pointer to a string containing the window .</param> /// <returns>A <see cref="WebDriverResult"/> value indicating success or failure.</returns> internal WebDriverResult GetCurrentWindowHandle(SafeInternetExplorerDriverHandle driverHandle, ref SafeStringWrapperHandle handleWrapperHandle) { IntPtr functionPointer = NativeMethods.GetProcAddress(nativeLibraryHandle, GetCurrentWindowHandleFunctionName); StringReturningDriverFunction getCurrentWindowHandleFunction = Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(StringReturningDriverFunction)) as StringReturningDriverFunction; WebDriverResult result = getCurrentWindowHandleFunction(driverHandle, ref handleWrapperHandle); return result; }
internal static extern WebDriverResult wdGetPageSource(SafeInternetExplorerDriverHandle driver, ref SafeStringWrapperHandle wrapper);