Java Code Examples for org.openqa.selenium.Keys#SHIFT

The following examples show how to use org.openqa.selenium.Keys#SHIFT . 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: CommonMethods.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
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 2
Source File: IndividualKeyboardActionsTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void keyDownActionWithoutProvidedElement() {
  final Keys keyToPress = Keys.SHIFT;

  KeyDownAction keyDown = new KeyDownAction(mockKeyboard, mockMouse, keyToPress);
  keyDown.perform();

  InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);
  order.verify(mockKeyboard).pressKey(keyToPress);
  order.verifyNoMoreInteractions();
}
 
Example 3
Source File: IndividualKeyboardActionsTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void keyDownActionOnAnElement() {
  final Keys keyToPress = Keys.SHIFT;

  KeyDownAction keyDown = new KeyDownAction(
      mockKeyboard, mockMouse, stubLocatable, keyToPress);

  keyDown.perform();

  InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);
  order.verify(mockMouse).click(mockCoordinates);
  order.verify(mockKeyboard).pressKey(keyToPress);
  order.verifyNoMoreInteractions();
}
 
Example 4
Source File: IndividualKeyboardActionsTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void keyUpOnAnAnElement() {
  final Keys keyToRelease = Keys.SHIFT;

  KeyUpAction upAction = new KeyUpAction(
      mockKeyboard, mockMouse, stubLocatable, keyToRelease);
  upAction.perform();

  InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);
  order.verify(mockMouse).click(mockCoordinates);
  order.verify(mockKeyboard).releaseKey(keyToRelease);
  order.verifyNoMoreInteractions();
}
 
Example 5
Source File: IndividualKeyboardActionsTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void testAllModifierKeysRegardedAsSuch() {
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.SHIFT);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_SHIFT);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.CONTROL);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_CONTROL);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.ALT);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_ALT);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.META);
  new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.COMMAND);
}