Example usage for org.openqa.selenium Keys NULL

List of usage examples for org.openqa.selenium Keys NULL

Introduction

In this page you can find the example usage for org.openqa.selenium Keys NULL.

Prototype

Keys NULL

To view the source code for org.openqa.selenium Keys NULL.

Click Source Link

Usage

From source file:com.machinepublishers.jbrowserdriver.Robot.java

License:Apache License

private static boolean isChord(CharSequence charSequence) {
    int[] codePoints = charSequence.codePoints().toArray();
    if (codePoints.length > 0) {
        char[] chars = Character.toChars(codePoints[codePoints.length - 1]);
        if (chars.length == 1) {
            return Keys.NULL.equals(Keys.getKeyFromUnicode(chars[0]));
        }/*from   w  w w  .  jav a 2s  .co  m*/
    }
    return false;
}

From source file:com.opera.core.systems.internal.input.KeyEvent.java

License:Apache License

/**
 * The Unicode PUA character for <code>NULL</code> signalises that all active modifier keys should
 * be released via a key up event./*from ww w. j a  v a  2 s .co m*/
 *
 * @return true if event is a modifier release, false otherwise
 */
public boolean isModifierRelease() {
    return getKey() == Keys.NULL;
}

From source file:io.github.seleniumquery.functions.jquery.forms.FocusFunction.java

License:Apache License

private static void focusElement(WebDriver driver, WebElement elementToBeFocused) {
    // #Cross-Driver
    if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver)
            && "html".equals(elementToBeFocused.getTagName())) {
        LOGGER.warn("The HTML element is not focusable in HtmlUnitDriver, even with a tabindex attribute!");
    }/*from  w  ww .j  a va2  s.  co  m*/
    elementToBeFocused.sendKeys(Keys.NULL);
}

From source file:org.auraframework.components.ui.popup.PopupUITest.java

License:Apache License

/**
 * Helper to create a custom popup trigger and closer.  Trigger is
 * selecting an input box; popup closing is done via clicking on a
 * button OR via the keyboard TAB key./*from  w  w w  .j  a v  a 2  s.c o  m*/
 * 
 * @param closeOnTabKey true if using the TAB key to close the popup;
 *      false if using the button to close the popup
 * @throws Exception
 */
private void verifyCustomTrigger(boolean closeOnTabKey) throws Exception {
    WebDriver driver = this.getDriver();
    String triggerLocator = "customTriggerInput";
    String buttonLocator = "customTriggerButton";
    String targetLocator = "customTriggerTargetContainer";
    String appUrl = "/uitest/popupTest.app";
    open(appUrl);

    // Click on the trigger and verify the popup opens
    waitForElementPresent("Trigger input box not present", driver.findElement(By.className(triggerLocator)));
    WebElement triggerInput = driver.findElement(By.className(triggerLocator));
    triggerInput.click();
    WebElement popContainerTgtElem = driver.findElement(By.className(targetLocator));
    waitForElementPresent("Popup did not launch", popContainerTgtElem);
    // Close the popup either by the TAB key or the close button
    if (closeOnTabKey) {
        Actions builder = new Actions(this.currentDriver);
        builder.sendKeys(Keys.TAB, Keys.NULL).build().perform();
    } else {
        WebElement customTriggerButton = driver.findElement(By.className(buttonLocator));
        customTriggerButton.click();
    }

    waitForElementAbsent("Popup did not close", popContainerTgtElem);
}

From source file:org.auraframework.integration.test.components.ui.popup.PopupUITest.java

License:Apache License

/**
 * Helper to create a custom popup trigger and closer.  Trigger is
 * selecting an input box; popup closing is done via clicking on a
 * button OR via the keyboard TAB key.//from   ww w.  j  a  va 2 s.co  m
 *
 * @param closeOnTabKey true if using the TAB key to close the popup;
 *                      false if using the button to close the popup
 * @throws Exception
 */
private void verifyCustomTrigger(boolean closeOnTabKey) throws Exception {
    WebDriver driver = this.getDriver();
    String triggerLocator = "customTriggerInput";
    String buttonLocator = "customTriggerButton";
    String targetLocator = "customTriggerTargetContainer";
    String appUrl = "/uitest/popupTest.app";
    open(appUrl);

    // Click on the trigger and verify the popup opens
    getAuraUITestingUtil().waitForElementDisplayed(By.cssSelector(triggerLocator),
            "Trigger input box not present");
    WebElement triggerInput = driver.findElement(By.className(triggerLocator));
    triggerInput.click();
    getAuraUITestingUtil().waitForElementDisplayed(By.cssSelector(targetLocator), "Popup did not launch");
    // Close the popup either by the TAB key or the close button
    if (closeOnTabKey) {
        Actions builder = new Actions(this.getDriver());
        builder.sendKeys(Keys.TAB, Keys.NULL).build().perform();
    } else {
        WebElement customTriggerButton = driver.findElement(By.className(buttonLocator));
        customTriggerButton.click();
    }

    getAuraUITestingUtil().waitForElementNotDisplayed(By.cssSelector(targetLocator), "Popup did not close");
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

private String mapAsciiKeyCodeToKey(int keyCode) {
    Map<Integer, Keys> keysMap = new HashMap<Integer, Keys>();
    keysMap.put(0, Keys.NULL);
    keysMap.put(8, Keys.BACK_SPACE);//ww  w  .  ja v a  2s .c om
    keysMap.put(9, Keys.TAB);
    keysMap.put(10, Keys.RETURN);
    keysMap.put(13, Keys.ENTER);
    keysMap.put(24, Keys.CANCEL);
    keysMap.put(27, Keys.ESCAPE);
    keysMap.put(32, Keys.SPACE);
    keysMap.put(42, Keys.MULTIPLY);
    keysMap.put(43, Keys.ADD);
    keysMap.put(44, Keys.SUBTRACT);
    keysMap.put(56, Keys.DECIMAL);
    keysMap.put(57, Keys.DIVIDE);
    keysMap.put(59, Keys.SEMICOLON);
    keysMap.put(61, Keys.EQUALS);
    keysMap.put(127, Keys.DELETE);
    Keys key = keysMap.get(keyCode);

    if (key == null) {
        Character c = (char) keyCode;
        return c.toString();
    }

    return key.toString();
}

From source file:org.testeditor.fixture.web.WebFixture.java

License:Open Source License

/**
 * Finds an element on the web page by its Element List key and inputs a
 * special key stroke in its context. <br />
 * <br />/*from  w ww .  j ava 2s. c o m*/
 * 
 * FitNesse usage..: |enter special key|arg1| <br />
 * FitNesse example: |enter special key|RIGHT| <br />
 * <br />
 * 
 * @param key
 *            the key stroke to enter (see
 *            https://code.google.com/p/selenium
 *            /source/browse/java/client/src/org/openqa/selenium/Keys.java)
 * @return the value of the target element; empty String, if the element
 *         could not be found or is not visible (i.e. hidden using CSS,
 *         etc.).
 */
public boolean enterSpecialKey(String key) {
    boolean result = false;

    Keys seleniumKey = Keys.NULL;
    try {
        seleniumKey = Keys.valueOf(key.toUpperCase());
    } catch (IllegalArgumentException e) {
        String message = "The specified key \"" + key
                + "\" is invalid and could not be found in selenium enum Keys!";
        LOGGER.error(message, e);
        throw new StopTestException(message);
    }

    Actions action = new Actions(webDriver);
    action.sendKeys(seleniumKey).build().perform();
    result = true;

    return result;
}