...20import org.openqa.selenium.Keys;21import org.openqa.selenium.interactions.Mouse;22import org.openqa.selenium.interactions.Keyboard;23import org.openqa.selenium.interactions.KeyDownAction;24import org.openqa.selenium.interactions.KeyUpAction;25import org.openqa.selenium.interactions.SendKeysAction;26import org.openqa.selenium.interactions.internal.Coordinates;27import org.openqa.selenium.internal.Locatable;28import static org.junit.Assert.assertTrue;29import static org.junit.Assert.fail;30import static org.mockito.Mockito.when;31/**32 * Unit test for all simple keyboard actions.33 * 34 */35public class IndividualKeyboardActionsTest {36 @Mock private Keyboard mockKeyboard;37 @Mock private Mouse mockMouse;38 @Mock private Coordinates mockCoordinates;39 @Mock private Locatable stubLocatable;40 final String keysToSend = "hello";41 @Before42 public void setUp() {43 MockitoAnnotations.initMocks(this);44 when(stubLocatable.getCoordinates()).thenReturn(mockCoordinates);45 }46 @Test47 public void keyDownActionWithoutProvidedElement() {48 final Keys keyToPress = Keys.SHIFT;49 KeyDownAction keyDown = new KeyDownAction(mockKeyboard, mockMouse, keyToPress);50 keyDown.perform();51 InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);52 order.verify(mockKeyboard).pressKey(keyToPress);53 order.verifyNoMoreInteractions();54 }55 @Test56 public void keyDownActionOnAnElement() {57 final Keys keyToPress = Keys.SHIFT;58 KeyDownAction keyDown = new KeyDownAction(59 mockKeyboard, mockMouse, stubLocatable, keyToPress);60 keyDown.perform();61 InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);62 order.verify(mockMouse).click(mockCoordinates);63 order.verify(mockKeyboard).pressKey(keyToPress);64 order.verifyNoMoreInteractions();65 }66 @Test67 public void keyUpActionWithoutProvidedElement() {68 final Keys keyToRelease = Keys.CONTROL;69 KeyUpAction keyUp = new KeyUpAction(mockKeyboard, mockMouse, keyToRelease);70 keyUp.perform();71 InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);72 order.verify(mockKeyboard).releaseKey(keyToRelease);73 order.verifyNoMoreInteractions();74 }75 @Test76 public void keyUpOnAnAnElement() {77 final Keys keyToRelease = Keys.SHIFT;78 KeyUpAction upAction = new KeyUpAction(79 mockKeyboard, mockMouse, stubLocatable, keyToRelease);80 upAction.perform();81 InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);82 order.verify(mockMouse).click(mockCoordinates);83 order.verify(mockKeyboard).releaseKey(keyToRelease);84 order.verifyNoMoreInteractions();85 }86 @Test87 public void sendKeysActionWithoutProvidedElement() {88 SendKeysAction sendKeys = new SendKeysAction(mockKeyboard, mockMouse, keysToSend);89 sendKeys.perform();90 InOrder order = Mockito.inOrder(mockKeyboard, mockMouse, mockCoordinates);91 order.verify(mockKeyboard).sendKeys(keysToSend);92 order.verifyNoMoreInteractions();...