Code example for JSONObject

Methods: getIntisNulloptString

0
 
  public ScrollHandler(IOSServerManager driver, WebDriverLikeRequest request) throws Exception {
    super(driver, request);
 
    JSONObject payload = request.getPayload();
    String elementId = payload.optString("element");
 
    Dimension screenSize = driver.getSession(request.getSession()).getNativeDriver().getScreenSize();
 
    Point fromPoint;
    if (!payload.isNull("element") && !elementId.equals("")) {
      RemoteWebNativeBackedElement element = (RemoteWebNativeBackedElement) getSession().getRemoteWebDriver().createElement(elementId);
      fromPoint = element.getLocation();
    } else { 
      fromPoint = new Point(screenSize.getWidth() / 2, screenSize.getHeight() / 2);
    } 
    fromPoint =  CoordinateUtils.forcePointOnScreen(fromPoint, screenSize);
    Point toPoint = new Point(fromPoint.getX() + payload.getInt("xoffset"), fromPoint.getY() + payload.getInt("yoffset"));
    toPoint = CoordinateUtils.forcePointOnScreen(toPoint, screenSize);
    String js = scrollTemplate
        .replace(":sessionId", request.getSession())
        .replace("fromX", Integer.toString(fromPoint.getX()))
        .replace("fromY", Integer.toString(fromPoint.getY()))