當前位置: 首頁>>代碼示例>>Java>>正文


Java Keys.valueOf方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:mcdcorp,項目名稱:opentest,代碼行數:27,代碼來源:ActionsKeyUp.java

示例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);
    }
}
 
開發者ID:mcdcorp,項目名稱:opentest,代碼行數:27,代碼來源:ActionsKeyDown.java

示例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;
}
 
開發者ID:xframium,項目名稱:xframium-java,代碼行數:26,代碼來源:KeyPressGesture.java

示例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;
            }
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:29,代碼來源:CommonMethods.java

示例5: getKeyOrCharacter

import org.openqa.selenium.Keys; //導入方法依賴的package包/類
private CharSequence getKeyOrCharacter(String key) {
    try {
        return Keys.valueOf(key.toUpperCase());
    } catch (IllegalArgumentException ex) {
        return key;
    }
}
 
開發者ID:alfa-laboratory,項目名稱:akita,代碼行數:8,代碼來源:DefaultSteps.java

示例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);
}
 
開發者ID:alfa-laboratory,項目名稱:akita,代碼行數:9,代碼來源:DefaultSteps.java


注:本文中的org.openqa.selenium.Keys.valueOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。