/// <summary>Releases a modifier key.</summary> /// <param name="key">The modifier key to send. Values are defined in Keys class.</param> /// <param name="webelement">The element to send keys. If None, sends a key to current focused element.</param> /// <returns></returns> public Actions keyUp(string key, WebElement webelement = null) { if (webelement == null) { _actions.KeyUp(key); } else { _actions.KeyUp(webelement._webElement, key); } return(this); }
/// <summary> /// Method performing a control click on multiple IWebElement objects. /// </summary> /// <param name="driver">IWebDriver object to execute method.</param> /// <param name="elements">The set of elements to perform the clicks.</param> public static void ControlClick(this IWebDriver driver, params IWebElement[] elements) { try { if (elements == null) { return; } if (elements.Length == 0) { return; } var action = new OpenQA.Selenium.Interactions.Actions(driver); action.KeyDown(Keys.Control); foreach (IWebElement element in elements) { action.MoveToElement(element); action.MoveToElement(element).Click(); } action.KeyUp(Keys.Control); action.Build().Perform(); } catch { } }
/// <summary> /// /// </summary> /// <param name="driver"></param> /// <param name="element"></param> /// <param name="key"></param> public static void Insert(this IWebDriver driver, IWebElement element, string key) { try { var action = new OpenQA.Selenium.Interactions.Actions(driver); action.MoveToElement(element); action.KeyDown(key); action.KeyUp(key.ToString()); action.Build().Perform(); } catch { } }
/// <summary> /// Method performing specific key pressed. /// </summary> /// <param name="element">IWebElement element that receives the click action.</param> /// <param name="keystr"></param> public static void Insert(this IWebElement element, string keystr) { try { var wrappedElement = element as IWrapsDriver; var driver = wrappedElement.WrappedDriver; var action = new OpenQA.Selenium.Interactions.Actions(driver); action.MoveToElement(element); action.KeyDown(keystr); action.KeyUp(keystr.ToString()); action.Build().Perform(); } catch { } }
/// <summary> /// Method performing a multi-click selection given two IWebElement objects. Use on a list of objects, it should also select all elements found within the given objects. /// </summary> /// <param name="driver">IWebDriver object to execute method.</param> /// <param name="firstElement">First IWebElement object onto which first click is performed.</param> /// <param name="secondElement">Second IWebElement object onto which second click is performed.</param> public static void ShiftClick(this IWebDriver driver, IWebElement firstElement, IWebElement secondElement) { try { var action = new OpenQA.Selenium.Interactions.Actions(driver); action.MoveToElement(firstElement); action.MoveToElement(firstElement).Click(); action.KeyDown(Keys.Shift); action.MoveToElement(secondElement); action.MoveToElement(secondElement).Click(); action.KeyUp(Keys.Shift); action.Build().Perform(); } catch { } }
/// <summary> /// Method performing a control click on multiple IWebElement objects. /// </summary> /// <param name="firstElement">First IWebElement object onto which first click is performed.</param> /// <param name="elements">The set of elements to perform the clicks.</param> public static void ControlClick(this IWebElement firstElement, params IWebElement[] elements) { try { var wrappedElement = firstElement as IWrapsDriver; var driver = wrappedElement.WrappedDriver; var action = new OpenQA.Selenium.Interactions.Actions(driver); action.MoveToElement(firstElement); action.MoveToElement(firstElement).Click(); action.KeyDown(Keys.Control); foreach (IWebElement element in elements) { action.MoveToElement(element); action.MoveToElement(element).Click(); } action.KeyUp(Keys.Control); action.Build().Perform(); } catch { } }
public IKeyActions KeyUp(BaseElement element, string theKey) { actions.KeyUp(element.IWebElement, theKey); return(this); }