/// <summary> /// Attempts to check if the supplied element is interactable. I.e. has the greatest Z index in its DOM area and is enabled. /// </summary> /// <param name="driver"></param> /// <param name="elementToQuery">The element to query.</param> /// <returns>If the element is interactable.</returns> public static bool IsInteractable(this IWebDriver driver, IWebElement elementToQuery) { var js = String.Format("return document.elementFromPoint({0}, {1});", elementToQuery.Location.X, elementToQuery.Location.Y); IJavaScriptExecutor executor = (IJavaScriptExecutor)driver; IWebElement elementFound = (IWebElement)executor.ExecuteScript(js); return(WebDriverSupport.ElementsMatch(elementToQuery, elementFound) && elementToQuery.Enabled); }
public static void SwitchToNewWindow(this IWebDriver driver) { WebDriverSupport.SwitchToNewWindow(driver); }
/// <summary> /// Executes the supplied javascript. /// </summary> /// <param name="driver">The driver instance to use.</param> /// <param name="strJs">The javascript code to execute.</param> public static void ExecuteJavascript(this IWebDriver driver, string strJs) { WebDriverSupport.ExecuteJavascript(driver, strJs); }
/// <summary> /// Convenience method for wrapping up the standard WebDriverWait construction. /// </summary> /// <param name="driver">The relevant driver instance.</param> /// <param name="message">The message to display upon timeout.</param> /// <param name="timeout">The length of time in seconds to poll for the condition.</param> /// <returns>The WebDriverWait instance</returns> /// <example> /// <code> /// driver.Wait().Until(d => checkbox.Displayed); /// </code> /// </example> public static WebDriverWait Wait(this IWebDriver driver, string message, int timeout = 5) { return(WebDriverSupport.Wait(driver, message, timeout)); }
//public static Retry Retry(this IWebDriver driver, int maxRetries = 5) //{ // return new Retry(driver, maxRetries); //} #region "Driver-centric Utils refs" /// <summary> /// Convenience method for wrapping up the standard WebDriverWait construction. /// </summary> /// <param name="driver">The relevant driver instance.</param> /// <param name="timeout">The length of time in seconds to poll for the condition.</param> /// <returns>The WebDriverWait instance</returns> /// <example> /// <code> /// driver.Wait().Until(d => checkbox.Displayed); /// </code> /// </example> public static WebDriverWait Wait(this IWebDriver driver, int timeout = 5) { return(WebDriverSupport.Wait(driver, timeout)); }
/// <summary> /// Sends the specified string to the element one character at a time with a short delay between pushes. /// This is primarily aimed at controls that do not deal with superfast input, such as elements with autosuggest events. /// </summary> /// <param name="element">The element to interact with.</param> /// <param name="text">The text to send slowly</param> /// <example> /// <code> /// myElement.SendKeysSlowly("Edinburgh"); /// </code> /// </example> public static void SendKeysSlowly(this IWebElement element, string text, int mSecDelay = 250) { WebDriverSupport.SendKeysSlowly(element, text, mSecDelay); }
/// <summary> /// On IE on saucelabs, when returning to a window with SwitchTo.Window() a click is required to refocus on the window /// </summary> /// <param name="targetLocator"></param> /// <param name="handle"></param> /// <param name="browser"></param> /// <param name="usingSauce"></param> /// <returns></returns> public static IWebDriver Window(this ITargetLocator targetLocator, string handle, string browser, bool usingSauce) { return(WebDriverSupport.Window(targetLocator, handle, browser, usingSauce)); }