本文整理匯總了Java中org.openqa.selenium.Keys.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Keys.valueOf方法的具體用法?Java Keys.valueOf怎麽用?Java Keys.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.Keys
的用法示例。
在下文中一共展示了Keys.valueOf方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
@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);
}
}
示例2: run
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
@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);
}
}
示例3: _executeGesture
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
String[] keyCodes = getKeyCode().split("\\+");
String keyPressed = null;
List<CharSequence> charSequence = new ArrayList<CharSequence>();
for (String keyCode : keyCodes) {
if (Keys.valueOf(keyCode) != null) {
charSequence.add(Keys.valueOf(keyCode.toUpperCase()));
} else {
throw new IllegalArgumentException( "Unsupported KeyPressGesture Type " + keyCode );
}
}
if (charSequence.size() > 0) {
Iterable<CharSequence> iterable = charSequence;
keyPressed = Keys.chord(iterable);
new Actions( webDriver ).moveToElement( webElement ).sendKeys(keyPressed).perform();
}
return true;
}
示例4: getKeyCode
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
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;
}
}
}
示例5: getKeyOrCharacter
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
private CharSequence getKeyOrCharacter(String key) {
try {
return Keys.valueOf(key.toUpperCase());
} catch (IllegalArgumentException ex) {
return key;
}
}
示例6: pushButtonOnKeyboard
import org.openqa.selenium.Keys; //導入方法依賴的package包/類
/**
* Эмулирует нажатие клавиш на клавиатуре
*/
@И("^выполнено нажатие на клавиатуре \"([^\"]*)\"$")
public void pushButtonOnKeyboard(String buttonName) {
Keys key = Keys.valueOf(buttonName.toUpperCase());
WebDriverRunner.getWebDriver().switchTo().activeElement().sendKeys(key);
}