org.openqa.selenium.interactions.Mouse Java Examples

The following examples show how to use org.openqa.selenium.interactions.Mouse. 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: MouseMoveToLocation.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Override
public Void call() {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();

  Coordinates elementLocation = null;
  if (elementProvided) {
    WebElement element = getKnownElements().get(elementId);
    elementLocation = ((Locatable) element).getCoordinates();
  }

  if (offsetsProvided) {
    mouse.mouseMove(elementLocation, xOffset, yOffset);
  } else {
    mouse.mouseMove(elementLocation);
  }
  return null;
}
 
Example #2
Source File: DefaultFieldDecoratorTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Test
public void testDecoratingProxyImplementsRequiredInterfaces() {
  final AllDriver driver = mock(AllDriver.class);
  final AllElement element = mock(AllElement.class);
  final Mouse mouse = mock(Mouse.class);

  when(driver.getMouse()).thenReturn(mouse);
  when(element.getCoordinates()).thenReturn(mock(Coordinates.class));
  when(driver.findElement(By.id("foo"))).thenReturn(element);

  Page page = new Page();
  PageFactory.initElements(driver, page);
  new Actions(driver).moveToElement(page.foo).build().perform();

  verify(driver).getKeyboard();
  verify(driver).getMouse();
  verify(element).getCoordinates();
  verify(mouse).mouseMove(any(Coordinates.class));
}
 
Example #3
Source File: DelegatingWebDriverTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testGetMouse()
{
    WebDriver driverWithInputDevices = Mockito.mock(WebDriver.class,
            withSettings().extraInterfaces(HasInputDevices.class));
    Mouse mouse = Mockito.mock(Mouse.class);
    when(((HasInputDevices) driverWithInputDevices).getMouse()).thenReturn(mouse);
    assertEquals(mouse, new DelegatingWebDriver(driverWithInputDevices).getMouse());
}
 
Example #4
Source File: DelegatingWebDriver.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Override
public Mouse getMouse()
{
    if (wrappedDriver instanceof HasInputDevices)
    {
        return ((HasInputDevices) wrappedDriver).getMouse();
    }
    throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);
}
 
Example #5
Source File: DeviceWebDriver.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Mouse getMouse()
{
    setLastAction();
    if ( webDriver instanceof HasInputDevices )
        return ((HasInputDevices) webDriver).getMouse();
    else
        return null;
}
 
Example #6
Source File: HtmlElement.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
/**
 * Forces a mouseDown event on the WebElement.
 */
public void mouseDown() {
    TestLogging.log("MouseDown " + this.toString());
    findElement();

    final Mouse mouse = ((HasInputDevices) driver).getMouse();
    mouse.mouseDown(null);
}
 
Example #7
Source File: HtmlElement.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
/**
 * Forces a mouseOver event on the WebElement.
 */
public void mouseOver() {
    TestLogging.log("MouseOver " + this.toString());
    findElement();

    // build and perform the mouseOver with Advanced User Interactions API
    // Actions builder = new Actions(driver);
    // builder.moveToElement(element).build().perform();
    final Locatable hoverItem = (Locatable) element;
    final Mouse mouse = ((HasInputDevices) driver).getMouse();
    mouse.mouseMove(hoverItem.getCoordinates());
}
 
Example #8
Source File: HtmlElement.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
/**
 * Forces a mouseUp event on the WebElement.
 */
public void mouseUp() {
    TestLogging.log("MouseUp " + this.toString());
    findElement();

    final Mouse mouse = ((HasInputDevices) driver).getMouse();
    mouse.mouseUp(null);
}
 
Example #9
Source File: ClickInSession.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public Void call() {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();

  if (leftMouseButton) {
    mouse.click(null);
  } else {
    mouse.contextClick(null);
  }

  return null;
}
 
Example #10
Source File: SingleKeyAction.java    From selenium with Apache License 2.0 5 votes vote down vote up
protected SingleKeyAction(Keyboard keyboard, Mouse mouse, Locatable locationProvider, Keys key) {
  super(keyboard, mouse, locationProvider);
  this.key = key;
  boolean isModifier = false;
  for (Keys modifier : MODIFIER_KEYS) {
    isModifier = isModifier || modifier.equals(key);
  }

  if (!isModifier) {
    throw new IllegalArgumentException("Key Down / Up events only make sense for modifier keys.");
  }
}
 
Example #11
Source File: EventFiringWebDriver.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public Mouse getMouse() {
  if (driver instanceof HasInputDevices) {
    return new EventFiringMouse(driver, dispatcher);
  }
  throw new UnsupportedOperationException("Underlying driver does not implement advanced"
      + " user interactions yet.");
}
 
Example #12
Source File: MouseUp.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Void call() {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.mouseUp(null);
  return null;
}
 
Example #13
Source File: DoubleClickInSession.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Void call() {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.doubleClick(null);
  return null;
}
 
Example #14
Source File: MouseDown.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Void call() {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.mouseDown(null);
  return null;
}
 
Example #15
Source File: StubDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Mouse getMouse() {
  return null;
}
 
Example #16
Source File: RemoteWebDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public Mouse getMouse() {
  return mouse;
}
 
Example #17
Source File: KeysRelatedAction.java    From selenium with Apache License 2.0 4 votes vote down vote up
protected KeysRelatedAction(Keyboard keyboard, Mouse mouse, Locatable locationProvider) {
  super(locationProvider);
  this.keyboard = keyboard;
  this.mouse = mouse;
}
 
Example #18
Source File: SingleKeyAction.java    From selenium with Apache License 2.0 4 votes vote down vote up
protected SingleKeyAction(Keyboard keyboard, Mouse mouse, Keys key) {
  this(keyboard, mouse, null, key);
}
 
Example #19
Source File: MouseAction.java    From selenium with Apache License 2.0 4 votes vote down vote up
protected MouseAction(Mouse mouse, Locatable locationProvider) {
  super(locationProvider);
  this.mouse = mouse;
}
 
Example #20
Source File: SeleniumWebDriver.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Mouse getMouse() {
  return driver.getMouse();
}
 
Example #21
Source File: WebDriverWrapper.java    From jsflight with Apache License 2.0 4 votes vote down vote up
@Override
public Mouse getMouse()
{
    return ((HasInputDevices)driver).getMouse();
}
 
Example #22
Source File: WebDriverDecorator.java    From teasy with MIT License 4 votes vote down vote up
@Override
public Mouse getMouse() {
    return ((HasInputDevices) driver).getMouse();
}
 
Example #23
Source File: QAFWebDriver.java    From qaf with MIT License votes vote down vote up
Mouse getMouse();