private CharSequence getKeyOrCharacter(String key) { try { return Keys.valueOf(key.toUpperCase()); } catch (IllegalArgumentException ex) { return key; } }
public Keys apply(OperaKey key) { return Keys.valueOf(key.name()); } });
private String toKeys(String keys) { if(isKeyCord(keys)) { keys = keys.substring(5); String[] items = keys.split("(?<!\\\\)\\|"); CharSequence[] charSequences = new CharSequence[items.length]; for(int i = 0; i < items.length;i++) { String item = items[i]; try { charSequences[i] = Keys.valueOf(item); } catch (IllegalArgumentException e) { charSequences[i] = item; } } return Keys.chord(charSequences); } return keys; }
/** * Эмулирует нажатие клавиш на клавиатуре */ @И("^выполнено нажатие на клавиатуре \"([^\"]*)\"$") public void pushButtonOnKeyboard(String buttonName) { Keys key = Keys.valueOf(buttonName.toUpperCase()); switchTo().activeElement().sendKeys(key); }
/** * Enters the given key into the current element, without clearing any current content * * Note this is to be used for 'special' keys defined by org.openqa.selenium.Keys * * @example SendKey Key.RETURN * @section Forms * @param key a value from {@link Keys} */ @Step("SendKey Key\\.(.+)") public void sendKey(final String key) { logger.debug("About to send key " + key + " to the current element"); webDriverContext().getCurrentElement().sendKeys(Keys.valueOf(key)); }
protected CharSequence parseKey(String key) { CharSequence s; try { s = Keys.valueOf(key.toUpperCase()); if (Keys.CONTROL.equals(s) && sendCommandForControlOnMac) { s = getSeleniumHelper().getControlOrCommand(); } } catch (IllegalArgumentException e) { s = key; } return s; }
/** * Press specified key on a keyboard Add corresponding parameter to allure * report * * @param keyName name of the key. See available key names in {@link Keys} */ @ActionTitle("ru.sbtqa.tag.pagefactory.press.key") public void pressKey(String keyName) { Keys key = Keys.valueOf(keyName.toUpperCase()); Actions actions = PageFactory.getActions(); actions.sendKeys(key).perform(); ParamsHelper.addParam(keyName, " is pressed"); }
/** * Press specified key on a keyboard Add corresponding parameter to allure * report * * @param keyName name of the key. See available key names in {@link Keys} */ @ActionTitle("ru.sbtqa.tag.pagefactory.press.key") public void pressKey(String keyName) { Keys key = Keys.valueOf(keyName.toUpperCase()); Actions actions = PageFactory.getActions(); actions.sendKeys(key).perform(); ParamsHelper.addParam("\"%s\" is pressed", new String[]{keyName}); }
/** * Focus a WebElement, and send specified key into it Add corresponding * parameter to allure report * * @param keyName name of the key. See available key names in {@link Keys} * @param elementTitle title of WebElement that accepts key commands * @throws ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException if * couldn't find element with required title */ @ActionTitle("ru.sbtqa.tag.pagefactory.press.key") public void pressKey(String keyName, String elementTitle) throws PageException { Keys key = Keys.valueOf(keyName.toUpperCase()); Actions actions = PageFactory.getActions(); actions.moveToElement(getElementByTitle(elementTitle)); actions.click(); actions.sendKeys(key); actions.build().perform(); ParamsHelper.addParam("\"%s\" is pressed by key \"%s\"", new String[]{elementTitle, keyName}); }
/** * Focus a WebElement, and send specified key into it Add corresponding * parameter to allure report * * @param keyName name of the key. See available key names in {@link Keys} * @param elementTitle title of WebElement that accepts key commands * @throws ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException if * couldn't find element with required title */ @ActionTitle("ru.sbtqa.tag.pagefactory.press.key") public void pressKey(String keyName, String elementTitle) throws PageException { Keys key = Keys.valueOf(keyName.toUpperCase()); Actions actions = PageFactory.getActions(); actions.moveToElement(PageFactoryUtils.getElementByTitle(PageContext.getCurrentPage(), elementTitle)); actions.click(); actions.sendKeys(key); actions.build().perform(); ParamsHelper.addParam(keyName, " is pressed on element " + elementTitle + "'"); }
return action.builder().keyDown(driver.findElement(loc.locatorAsString(target)).toString(), Keys.valueOf(value)); case KEYPRESS: case KEYPRESSANDWAIT: case KEYUP: case KEYUPANDWAIT: return action.builder().keyUp(driver.findElement(loc.locatorAsString(target)).toString(), Keys.valueOf(value)); case METAKEYDOWN: case METAKEYDOWNANDWAIT: