Package org.openqa.selenium

Examples of org.openqa.selenium.Dimension


  @Override
  public Response handle() throws Exception {
    String ref = getRequest().getVariableValue(":reference");
    RemoteWebNativeBackedElement element = (RemoteWebNativeBackedElement) getWebDriver().createElement(ref);
    Dimension size = element.getSize();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(size);
    return res;
View Full Code Here


    String elementId = payload.optString("element");
    if (RemoteIOSWebDriver.isPlainElement(elementId)) {
      NodeId nodeId = RemoteIOSWebDriver.plainNodeId(elementId);
      setJS(plainTemplate.generate(request.getSession(), nodeId.getId()));
    } else {
      Dimension screenSize = getNativeDriver().getScreenSize();
      RemoteWebNativeBackedElement element = (RemoteWebNativeBackedElement) getWebDriver().createElement(elementId);
      Point tapPoint = element.getLocation(RemoteWebElement.ElementPosition.CENTER);
      tapPoint = CoordinateUtils.forcePointOnScreen(tapPoint, screenSize);
      setJS(nativeTemplate.generate(request.getSession(), tapPoint.getX(), tapPoint.getY()));
    }
View Full Code Here

  public ScrollNHandler(IOSServerManager driver, WebDriverLikeRequest request) throws Exception {
    super(driver, request);

    JSONObject payload = request.getPayload();
    Dimension screenSize = getNativeDriver().getScreenSize();
    Point offset = new Point(payload.getInt("xoffset"), payload.getInt("yoffset"));
    String elementId = payload.optString("element");
    if (!payload.isNull("element") && !elementId.equals("")) {
      if (RemoteIOSWebDriver.isPlainElement(elementId)) {
        NodeId nodeId = RemoteIOSWebDriver.plainNodeId(elementId);
View Full Code Here

  public FlickNHandler(IOSServerManager driver, WebDriverLikeRequest request) throws Exception {
    super(driver, request);

    JSONObject payload = request.getPayload();
    Dimension screenSize = getNativeDriver().getScreenSize();
    String elementId = payload.optString("element");
    if (!payload.isNull("element") && !elementId.equals("")) {
      Point offset = new Point(payload.getInt("xoffset"), payload.getInt("yoffset"));
      double speed = payload.optDouble("speed", 1.0);
      if (RemoteIOSWebDriver.isPlainElement(elementId)) {
View Full Code Here

    String elementId = payload.optString("element");
    if (RemoteIOSWebDriver.isPlainElement(elementId)) {
      NodeId nodeId = RemoteIOSWebDriver.plainNodeId(elementId);
      setJS(plainTemplate.generate(request.getSession(), nodeId.getId()));
    } else {
      Dimension screenSize = getNativeDriver().getScreenSize();
      RemoteWebNativeBackedElement element = (RemoteWebNativeBackedElement) getWebDriver().createElement(elementId);
      Point tapPoint = element.getLocation(RemoteWebElement.ElementPosition.CENTER);
      tapPoint = CoordinateUtils.forcePointOnScreen(tapPoint, screenSize);
      setJS(nativeTemplate.generate(request.getSession(), tapPoint.getX(), tapPoint.getY()));
    }
View Full Code Here

      throws Exception {
    // web stuff.
    //scrollIntoViewIfNeeded();
    Point po = findPosition();

    Dimension dim = getInspector().getSize();
    int webPageWidth = getInspector().getInnerWidth();
    if (dim.getWidth() != webPageWidth) {
      log.fine("BUG : dim.getWidth()!=webPageWidth");
    }

    Criteria c = new TypeCriteria(UIAWebView.class);
    String json = c.stringify().toString();
    StringBuilder script = new StringBuilder();
    script.append("var root = UIAutomation.cache.get('1');");
    script.append("var webview = root.element(-1," + json + ");");
    script.append("var webviewSize = webview.rect();");
    script.append("var ratioX = 1.0 * webviewSize.size.width / " + dim.getWidth() + ";");
    script.append("var ratioY = 1.0 * webviewSize.size.height / " + dim.getHeight() + ";");
    int top = po.getY();
    int left = po.getX();
    // switch +1 to +2 in next, with +1 some clicks in text fields didn't bring up the
    // keyboard, the text field would get focus, but the keyboard would not launch
    // also with this change 17 miscellaneous selenium tests got fixed
    switch (position) {
      case TOP_LEFT: {
        script.append("var top = (" + top + "*ratioX);");
        script.append("var left = (" + left + "*ratioY);");
        break;
      }
      case CENTER: {
        Dimension size = getSize();
        script.append("var top = (" + top + " + " + size.getHeight() + " / 2) * ratioX;");
        script.append("var left = (" + left + " + " + size.getWidth() + " / 2) * ratioY;");
        break;
      }
    }

    script.append("var x = left;");
View Full Code Here

    return getCenterPoint(x, y, width, height);
  }

  public static Point getCenterPointFromElement(RemoteWebElement element) throws Exception {
    Point location = element.getLocation(RemoteWebElement.ElementPosition.TOP_LEFT);
    Dimension size = element.getSize();
    return getCenterPoint(location.getX(), location.getY(), size.getWidth(), size.getHeight());
  }
View Full Code Here

                .put("returnByValue", false));

    JSONObject response = sendCommand(cmd);
    String s = cast(response);
    JSONObject o = new JSONObject(s);
    Dimension dim = new Dimension(o.getInt("width"), o.getInt("height"));
    return dim;

  }
View Full Code Here

    String elementId = payload.optString("element");
    if (RemoteIOSWebDriver.isPlainElement(elementId)) {
      NodeId nodeId = RemoteIOSWebDriver.plainNodeId(elementId);
      setJS(plainTemplate.generate(request.getSession(), nodeId.getId()));
    } else {
      Dimension screenSize = getNativeDriver().getScreenSize();
      RemoteWebNativeBackedElement element = (RemoteWebNativeBackedElement) getWebDriver().createElement(elementId);
      Point tapPoint = element.getLocation(RemoteWebElement.ElementPosition.CENTER);
      tapPoint = CoordinateUtils.forcePointOnScreen(tapPoint, screenSize);
      setJS(nativeTemplate.generate(request.getSession(), tapPoint.getX(), tapPoint.getY()));
    }
View Full Code Here

  @Test
  public void builderPopulates() {
    OperaMobileEmulation.Builder builder = OperaMobileEmulation.builder();

    builder.setResolution(new Dimension(100, 200));
    builder.setPPI(300);
    builder.setProfileName("hoobaflooba");
    builder.setIME(EmulationProfile.IME.KEYPAD);
    builder.setUserAgent(OperaMobileEmulation.UserAgent.MEEGO);

    EmulationProfile profile = builder.build();

    assertEquals(new Dimension(100, 200), profile.getResolution());
    assertEquals(300, profile.getPPI());
    assertEquals("hoobaflooba", profile.getProfileName());
    assertEquals(EmulationProfile.IME.KEYPAD, profile.getIME());
    assertEquals(OperaMobileEmulation.UserAgent.MEEGO.toString(), profile.getUserAgent());
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.Dimension

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.