Java Code Examples for org.openqa.selenium.Keys#valueOf()
The following examples show how to use
org.openqa.selenium.Keys#valueOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionsKeyUp.java From opentest with MIT License | 6 votes |
@Override public void run() { super.run(); By locator = this.readLocatorArgument("locator", null); String keyValue = this.readStringArgument("key", null); String charValue = this.readStringArgument("char", null); CharSequence key = null; if (keyValue != null) { key = Keys.valueOf(keyValue); } else if (charValue != null) { key = charValue; } else { throw new RuntimeException( "You must either provide the \"key\" argument or the \"char\" " + "argument to specify the key you want to press."); } if (locator != null) { WebElement element = this.getElement(locator); SeleniumTestAction.getActionsInstance().keyUp(element, key); } else { SeleniumTestAction.getActionsInstance().keyUp(key); } }
Example 2
Source File: ActionsKeyDown.java From opentest with MIT License | 6 votes |
@Override public void run() { super.run(); By locator = this.readLocatorArgument("locator", null); String keyValue = this.readStringArgument("key", null); String charValue = this.readStringArgument("char", null); CharSequence key = null; if (keyValue != null) { key = Keys.valueOf(keyValue); } else if (charValue != null) { key = charValue; } else { throw new RuntimeException( "You must either provide the \"key\" argument or the \"char\" " + "argument to specify the key you want to press."); } if (locator != null) { WebElement element = this.getElement(locator); SeleniumTestAction.getActionsInstance().keyDown(element, key); } else { SeleniumTestAction.getActionsInstance().keyDown(key); } }
Example 3
Source File: CommonMethods.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
Keys getKeyCode(String data) { switch (data) { case "tab": return Keys.TAB; case "enter": return Keys.ENTER; case "shift": return Keys.SHIFT; case "ctrl": return Keys.CONTROL; case "alt": return Keys.ALT; case "esc": return Keys.ESCAPE; case "delete": return Keys.DELETE; case "backspace": return Keys.BACK_SPACE; case "home": return Keys.HOME; default: try { return Keys.valueOf(data.toUpperCase()); } catch (Exception ex) { return null; } } }
Example 4
Source File: RoundUpSteps.java From akita with Apache License 2.0 | 5 votes |
/** * Эмулирует нажатие клавиш на клавиатуре */ @И("^выполнено нажатие на клавиатуре \"([^\"]*)\"$") @And("^pressed \"([^\"]*)\" key $") public void pushButtonOnKeyboard(String buttonName) { Keys key = Keys.valueOf(buttonName.toUpperCase()); switchTo().activeElement().sendKeys(key); }
Example 5
Source File: RoundUpSteps.java From akita with Apache License 2.0 | 5 votes |
private CharSequence getKeyOrCharacter(String key) { try { return Keys.valueOf(key.toUpperCase()); } catch (IllegalArgumentException ex) { return key; } }
Example 6
Source File: BrowserTest.java From hsac-fitnesse-fixtures with Apache License 2.0 | 5 votes |
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; }