@Override public Mouse getMouse() { if (driver instanceof HasInputDevices) return ((HasInputDevices) driver).getMouse(); return null; } }
public Actions(WebDriver driver) { this.driver = Objects.requireNonNull(driver); if (driver instanceof HasInputDevices) { HasInputDevices deviceOwner = (HasInputDevices) driver; this.jsonKeyboard = deviceOwner.getKeyboard(); this.jsonMouse = deviceOwner.getMouse(); } else { this.jsonKeyboard = null; this.jsonMouse = null; } }
@Override public Keyboard getKeyboard() { if (driver instanceof HasInputDevices) return ((HasInputDevices) driver).getKeyboard(); return null; }
public Keyboard getKeyboard() { return ((HasInputDevices)driver).getKeyboard(); }
public Mouse getMouse() { return ((HasInputDevices)driver).getMouse(); } }
@Before public final void setUp() { driver = mock(HtmlUnitDriver.class, withSettings().extraInterfaces(HasInputDevices.class)); mouse = mock(Mouse.class); keyboard = mock(Keyboard.class); webElement = mock(HtmlUnitWebElement.class); GrapheneContext.setContextFor(new GrapheneConfiguration(), driver, Default.class); GrapheneRuntime.pushInstance(new DefaultGrapheneRuntime()); when(((HasInputDevices) driver).getMouse()).thenReturn(mouse); when(((HasInputDevices) driver).getKeyboard()).thenReturn(keyboard); }
@Override public Object generateProxy(HasInputDevices base) { return base.getKeyboard(); }
@Override public Object generateProxy(HasInputDevices base) { return base.getMouse(); }
@Test public void testActionsProviderLookup() { // having ActionsProvider provider = new ActionsProvider(); Mouse mouse = mock(Mouse.class); Keyboard keyboard = mock(Keyboard.class); when(((HasInputDevices) driver).getMouse()).thenReturn(mouse); when(((HasInputDevices) driver).getKeyboard()).thenReturn(keyboard); // when Actions actions = (Actions) provider.lookup(null, null); actions.click().perform(); // then verify(mouse).click(null); verifyNoMoreInteractions(mouse, keyboard); } }
@Override public Object generateProxy(HasInputDevices base) { return base.getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices) webDriver).getMouse(); }
@Before public void setUp() { when(((HasInputDevices) driver).getKeyboard()).thenReturn(new Keyboard() { @Override public void sendKeys(CharSequence... keysToSend) { when(((HasInputDevices) driver).getMouse()).thenReturn(new Mouse() {
@Override public Keyboard getKeyboard() { return ((HasInputDevices) webDriver).getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices) webDriver).getMouse(); }
@Override public Keyboard getKeyboard() { return ((HasInputDevices) webDriver).getKeyboard(); }
@Override public Object generateProxy(HasInputDevices base) { return base.getMouse(); }
protected Keyboard delegateKeyboard() { return ((HasInputDevices) delegate).getKeyboard(); } }
@Override public Mouse getMouse() { return ((HasInputDevices) webDriver).getMouse(); }
@Override public Keyboard getKeyboard() { return ((HasInputDevices) webDriver).getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices) webDriver).getMouse(); }