Java 类org.openqa.selenium.interactions.HasInputDevices 实例源码

项目:grid-refactor-remote-server    文件:MouseMoveToLocation.java   
@Override
public Void call() throws Exception {
  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;
}
项目:preferanser    文件:EndUserSteps.java   
@Step
public EndUserSteps dragsCardToOtherLocation(Card card, TableLocation fromLocation, TableLocation toLocation) {
    TablePage page = getTablePage();

    Optional<WebElementFacade> maybeCard = page.getCardAtTableLocationElement(card, fromLocation);
    assertTrue(maybeCard.isPresent());

    Optional<WebElementFacade> maybeTableLocation = page.getTableLocationElement(toLocation);
    assertTrue(maybeTableLocation.isPresent());

    Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
    mouse.mouseMove(maybeCard.get().getCoordinates(), 3, 3); // grab the top left corner
    mouse.mouseDown(null); // at the current location
    mouse.mouseMove(maybeTableLocation.get().getCoordinates());
    mouse.mouseUp(maybeTableLocation.get().getCoordinates());
    return this;
}
项目:xframium-java    文件:DeviceWebDriver.java   
@Override
public Keyboard getKeyboard()
{
    setLastAction();
    if ( webDriver instanceof HasInputDevices )
        return ((HasInputDevices) webDriver).getKeyboard();
    else
        return null;
}
项目:xframium-java    文件:DeviceWebDriver.java   
@Override
public Mouse getMouse()
{
    setLastAction();
    if ( webDriver instanceof HasInputDevices )
        return ((HasInputDevices) webDriver).getMouse();
    else
        return null;
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _moveTo()
{
    WebElement webElement = getElement();
    if ( webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0 )
    {
        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).moveTo( webElement ).perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen )
                    new TouchActions( getWebDriver() ).moveToElement( webElement ).build().perform();
                else
                    new Actions( getWebDriver() ).moveToElement( webElement ).build().perform();
            }

            return true;
        }
    }

    return false;
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _clickFor( int length )
{
    WebElement webElement = getElement();
    if ( webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0 )
    {
        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver<?>) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).press( webElement ).waitAction( Duration.ofMillis( length ) ).release().perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                double x = webElement.getLocation().getX() + (webElement.getSize().getWidth() / 2);
                double y = webElement.getLocation().getY() + (webElement.getSize().getHeight() / 2);

                int percentX = (int) ( x / getWebDriver().manage().window().getSize().getWidth() * 100.0 );
                int percentY = (int) ( y / getWebDriver().manage().window().getSize().getHeight() * 100.0 );

                try
                {
                    new TouchActions( getWebDriver() ).longPress( webElement ).build().perform();
                }
                catch ( Exception e )
                {
                    ((DeviceWebDriver) getWebDriver()).getCloud().getCloudActionProvider().tap( (DeviceWebDriver) getWebDriver(), new PercentagePoint( percentX, percentY, true  ), length );
                }

            }

            return true;
        }
    }

    return false;
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _press()
{
    WebElement webElement = getElement();
    if ( webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0 )
    {
        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).press( webElement ).perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen )
                    new TouchActions( getWebDriver() ).clickAndHold( webElement ).build().perform();
                else
                    new Actions( getWebDriver() ).clickAndHold( webElement ).build().perform();
            }

            return true;
        }
    }

    return false;
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _mouseDoubleClick()
{
    WebElement webElement = getElement();
    if ( webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0 )
    {
        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).tap( webElement ).tap( webElement ).perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen )
                    new TouchActions( getWebDriver() ).doubleClick().build().perform();
                else
                    new Actions( getWebDriver() ).doubleClick( webElement ).build().perform();
            }

            return true;
        }
    }

    return false;
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _release()
{
    WebElement webElement = getElement();
    if ( webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0 )
    {
        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).release().perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen )
                    new TouchActions( getWebDriver() ).release().build().perform();
                else
                    new Actions( getWebDriver() ).release().build().perform();
            }
            return true;
        }
    }

    return false;
}
项目:seleniumtestsframework    文件:HtmlElement.java   
/**
 * 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);
}
项目:seleniumtestsframework    文件:HtmlElement.java   
/**
 * 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());
}
项目:seleniumtestsframework    文件:HtmlElement.java   
/**
 * 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);
}
项目:grid-refactor-remote-server    文件:ClickInSession.java   
@Override
public Void call() throws Exception {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();

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

  return null;
}
项目:grid-refactor-remote-server    文件:SendKeyToActiveElement.java   
@Override
public Void call() throws Exception {
  Keyboard keyboard = ((HasInputDevices) getDriver()).getKeyboard();

  String[] keysToSend = keys.toArray(new String[0]);
  keyboard.sendKeys(keysToSend);

  return null;
}
项目:teasy    文件:WebDriverDecorator.java   
@Override
public Keyboard getKeyboard() {
    return ((HasInputDevices) driver).getKeyboard();
}
项目:teasy    文件:WebDriverDecorator.java   
@Override
public Mouse getMouse() {
    return ((HasInputDevices) driver).getMouse();
}
项目:xframium-java    文件:SeleniumElement.java   
public boolean _clickAt( int offsetX, int offsetY )
{
    WebElement webElement = getElement();

    if ( webElement != null )
    {

        Dimension elementSize = webElement.getSize();

        int useX = (int) ((double) elementSize.getWidth() * ((double) offsetX / 100.0));
        int useY = (int) ((double) elementSize.getHeight() * ((double) offsetY / 100.0));

        if ( log.isInfoEnabled() )
            log.info( "Clicking " + useX + "," + useY + " pixels relative to " + getName() );

        if ( getWebDriver() instanceof HasInputDevices )
        {
            if ( isTimed() )
                getActionProvider().startTimer( (DeviceWebDriver) getWebDriver(), this, getExecutionContext() );

            if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver )
            {
                new TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).moveTo( webElement ).tap( webElement, useX, useY ).perform();
            }
            else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver )
            {
                if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen )
                    new TouchActions( getWebDriver() ).moveToElement( webElement, useX, useY ).click().build().perform();
                else
                    new Actions( getWebDriver() ).moveToElement( webElement, useX, useY ).click().build().perform();
            }

            return true;
        }

        return true;
    }

    return false;

}
项目:easytest    文件:DeviceWebDriver.java   
@Override
public Keyboard getKeyboard() {
    return ((HasInputDevices) driver).getKeyboard();
}
项目:easytest    文件:DeviceWebDriver.java   
@Override
public Mouse getMouse() {
    return ((HasInputDevices) driver).getMouse();
}
项目:mario    文件:WebRobot.java   
private HasInputDevices inputDevices() {
    if (!(driver instanceof HasInputDevices)) {
        throw new UnsupportedOperationException("Driver has no input device");
    }
    return (HasInputDevices) driver;
}
项目:easyium-java    文件:WebDriver.java   
/**
 * @return the {@link Keyboard} of current driver
 */
public Keyboard getKeyboard() {
    return ((HasInputDevices) seleniumWebDriver()).getKeyboard();
}
项目:easyium-java    文件:WebDriver.java   
/**
 * @return the {@link Mouse} of current driver
 */
public Mouse getMouse() {
    return ((HasInputDevices) seleniumWebDriver()).getMouse();
}
项目:jsflight    文件:WebDriverWrapper.java   
@Override
public Keyboard getKeyboard()
{
    return ((HasInputDevices)driver).getKeyboard();
}
项目:jsflight    文件:WebDriverWrapper.java   
@Override
public Mouse getMouse()
{
    return ((HasInputDevices)driver).getMouse();
}
项目:che    文件:GenericActionsTest.java   
@BeforeMethod
public void setUp() throws Exception {
  webDriver =
      Mockito.mock(
          WebDriver.class, Mockito.withSettings().extraInterfaces(HasInputDevices.class));
}
项目:che    文件:MacOSActionsTest.java   
@BeforeMethod
public void setUp() throws Exception {
  webDriver =
      Mockito.mock(
          WebDriver.class, Mockito.withSettings().extraInterfaces(HasInputDevices.class));
}
项目:grid-refactor-remote-server    文件:MouseDown.java   
@Override
public Void call() throws Exception {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.mouseDown(null);
  return null;
}
项目:grid-refactor-remote-server    文件:DoubleClickInSession.java   
@Override
public Void call() throws Exception {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.doubleClick(null);
  return null;
}
项目:grid-refactor-remote-server    文件:MouseUp.java   
@Override
public Void call() throws Exception {
  Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  mouse.mouseUp(null);
  return null;
}
项目:web-test-framework    文件:Driver.java   
/**
 *
 * @return
 */
@Override
public Keyboard getKeyboard() {
  return ((HasInputDevices) driver).getKeyboard();
}
项目:web-test-framework    文件:Driver.java   
/**
 *
 * @return
 */
@Override
public Mouse getMouse() {
  return ((HasInputDevices) driver).getMouse();
}
项目:cinnamon    文件:HoverAction.java   
@Override
public void perform(final WebElement target) {
    final Locatable hoverItem = (Locatable) target;
    final Mouse mouse = ((HasInputDevices) webDriver).getMouse();
    mouse.mouseMove(hoverItem.getCoordinates());
}
项目:seleniumcapsules    文件:Browser.java   
@Override
default Keyboard getKeyboard() {
    HasInputDevices t = (HasInputDevices) get();
    return t.getKeyboard();
}
项目:seleniumcapsules    文件:Browser.java   
@Override
default Mouse getMouse() {
    HasInputDevices t = (HasInputDevices) get();
    return t.getMouse();
}
项目:minium    文件:StatefulWebDriver.java   
@Override
public Keyboard getKeyboard() {
    return ((HasInputDevices) webDriver).getKeyboard();
}
项目:minium    文件:StatefulWebDriver.java   
@Override
public Mouse getMouse() {
    return ((HasInputDevices) webDriver).getMouse();
}
项目:minium    文件:BaseDocumentWebDriver.java   
@Override
public Keyboard getKeyboard() {
    return ((HasInputDevices) webDriver).getKeyboard();
}
项目:minium    文件:BaseDocumentWebDriver.java   
@Override
public Mouse getMouse() {
    return ((HasInputDevices) webDriver).getMouse();
}
项目:minium    文件:DelegatorWebDriver.java   
protected Mouse delegateMouse() {
    return ((HasInputDevices) delegate).getMouse();
}
项目:minium    文件:DelegatorWebDriver.java   
protected Keyboard delegateKeyboard() {
    return ((HasInputDevices) delegate).getKeyboard();
}