/** * Get the special key representation, {@link Keys}, of the supplied character if there is one. If * there is no special key tied to this character, null will be returned. * * @param key unicode character code * @return special key linked to the character code, or null if character is not a special key */ private static Keys getKeyFromUnicode(char key) { for (Keys unicodeKey : Keys.values()) { if (unicodeKey.charAt(0) == key) { return unicodeKey; } } return null; }
/** * Get the special key representation, {@link Keys}, of the supplied character if there is one. If * there is no special key tied to this character, null will be returned. * * @param key unicode character code * @return special key linked to the character code, or null if character is not a special key */ public static Keys getKeyFromUnicode(char key) { for (Keys unicodeKey : values()) { if (unicodeKey.charAt(0) == key) { return unicodeKey; } } return null; } }
@Override public void keyDown(Keys theKey) throws WidgetException { try { Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); for (org.openqa.selenium.Keys key : org.openqa.selenium.Keys.values()) { if (key.name().equals(theKey.name())) { builder.keyDown(getWebElement(), key).build().perform(); break; } } } } catch (Exception e) { throw new WidgetException("Error while performing key down using " + theKey.name(), getByLocator(), e); } }
@Override public void keyUp(Keys theKey) throws WidgetException { try { Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); for (org.openqa.selenium.Keys key : org.openqa.selenium.Keys.values()) { if (key.name().equals(theKey.name())) { builder.keyUp(getWebElement(), key).build().perform(); break; } } } } catch (Exception e) { throw new WidgetException("Error while performing key up using " + theKey.name(), getByLocator(), e); } }
@Override public void keyDown(Keys theKey) throws WidgetException { try { Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); for (org.openqa.selenium.Keys key : org.openqa.selenium.Keys.values()) { if (key.name().equals(theKey.name())) { builder.keyDown(getWebElement(), key).build().perform(); break; } } } } catch (Exception e) { throw new WidgetException("Error while performing key down using " + theKey.name(), getByLocator(), e); } }
@Override public void keyUp(Keys theKey) throws WidgetException { try { Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); for (org.openqa.selenium.Keys key : org.openqa.selenium.Keys.values()) { if (key.name().equals(theKey.name())) { builder.keyUp(getWebElement(), key).build().perform(); break; } } } } catch (Exception e) { throw new WidgetException("Error while performing key up using " + theKey.name(), getByLocator(), e); } }
put("nbsp", "\u00A0"); for (Keys key : Keys.values()) put("KEY_" + key.name(), key.toString());