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

项目:xframium-java    文件:NumberPickerSetMethod.java   
private void clickAt( WebElement webElement, WebDriver webDriver, int x, int y )
{
    if ( webElement != null )
    {

        Dimension elementSize = webElement.getSize();

        int useX = (int) ((double) elementSize.getWidth() * ((double) x / 100.0));
        int useY = (int) ((double) elementSize.getHeight() * ((double) y / 100.0));


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

    }
}
项目:xframium-java    文件:DeviceWebDriver.java   
@Override
public TouchScreen getTouch()
{
    setLastAction();
    if ( webDriver instanceof HasTouchScreen )
        return ((HasTouchScreen) webDriver).getTouch();
    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 _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;
}
项目:grid-refactor-remote-server    文件:SingleTapOnElement.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();
  WebElement element = getKnownElements().get(elementId);
  Coordinates elementLocation = ((Locatable) element).getCoordinates();

  touchScreen.singleTap(elementLocation);

  return null;
}
项目:grid-refactor-remote-server    文件:Down.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();

  touchScreen.down(x, y);

  return null;
}
项目:grid-refactor-remote-server    文件:Flick.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();

  if (elementId != null) {
    WebElement element = getKnownElements().get(elementId);
    Coordinates elementLocation = ((Locatable) element).getCoordinates();
    touchScreen.flick(elementLocation, xOffset, yOffset, speed);
  } else {
    touchScreen.flick(xSpeed, ySpeed);
  }

  return null;
}
项目:grid-refactor-remote-server    文件:Up.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();

  touchScreen.up(x, y);

  return null;
}
项目:grid-refactor-remote-server    文件:DoubleTapOnElement.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();
  WebElement element = getKnownElements().get(elementId);
  Coordinates elementLocation = ((Locatable) element).getCoordinates();

  touchScreen.doubleTap(elementLocation);

  return null;
}
项目:grid-refactor-remote-server    文件:LongPressOnElement.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();
  WebElement element = getKnownElements().get(elementId);
  Coordinates elementLocation = ((Locatable) element).getCoordinates();
  touchScreen.longPress(elementLocation);

  return null;
}
项目:grid-refactor-remote-server    文件:Move.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();

  touchScreen.move(x, y);

  return null;
}
项目:grid-refactor-remote-server    文件:Scroll.java   
@Override
public Void call() throws Exception {
  TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch();

  if (elementId != null) {
    WebElement element = getKnownElements().get(elementId);
    Coordinates elementLocation = ((Locatable) element).getCoordinates();
    touchScreen.scroll(elementLocation, xOffset, yOffset);
  } else {
    touchScreen.scroll(xOffset, yOffset);
  }
  return null;
}
项目:grid-refactor-remote-server    文件:DefaultSession.java   
private DesiredCapabilities getDescription(WebDriver instance, Capabilities capabilities) {
  DesiredCapabilities caps = new DesiredCapabilities(capabilities.asMap());
  caps.setJavascriptEnabled(instance instanceof JavascriptExecutor);
  if (instance instanceof TakesScreenshot) {
    caps.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
  }
  if (instance instanceof LocationContext) {
    caps.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT, true);
  }
  if (instance instanceof ApplicationCache) {
    caps.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true);
  }
  if (instance instanceof NetworkConnection) {
    caps.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true);
  }
  if (instance instanceof WebStorage) {
    caps.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, true);
  }
  if (instance instanceof FindsByCssSelector) {
    caps.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true);
  }
  if (instance instanceof Rotatable) {
    caps.setCapability(CapabilityType.ROTATABLE, true);
  }
  if (instance instanceof HasTouchScreen) {
    caps.setCapability(CapabilityType.HAS_TOUCHSCREEN, true);
  }
  return caps;
}
项目: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 TouchScreen getTouch() {
    return ((HasTouchScreen) driver).getTouch();
}
项目:selendroid    文件:TouchTestBase.java   
@Before
public void checkHasTouchScreen() {
  assumeThat(driver(), instanceOf(HasTouchScreen.class));
}