Source:
public PerformTouchAction(WebDriver webDriver) { mobileDriver = NewDriverProvider.getMobileDriver(); driver = webDriver; JavascriptExecutor js = (JavascriptExecutor) driver; if (mobileDriver.getContext() != "NATIVE_APP") { mobileDriver.context("NATIVE_APP"); } nativeHeight = mobileDriver.manage().window().getSize().height; nativeWidth = mobileDriver.manage().window().getSize().width; int startX = nativeWidth / 2; int startY = nativeHeight - 1; int endX = startX; int endY = nativeHeight / 3; int duration = startY - endY; try { mobileDriver.swipe(startX, startY, endX, endY, duration); } catch (Exception e) try { Thread.sleep(duration * 3); } catch(Exception e) if (mobileDriver.getContext() != "WEBVIEW_1") { mobileDriver.context("WEBVIEW_1"); } js.executeScript("window.scrollTo(0, 0)"); appWebviewHeight = Integer.parseInt(js.executeScript("return $(window).height()").toString()); appWebviewWidth = Integer.parseInt(js.executeScript("return $(window).width()").toString()); loadedPageHeight = Integer.parseInt(js.executeScript("return $(document).height()").toString()); loadedPageWidth = Integer.parseInt(js.executeScript("return $(document).width()").toString()); ratio = nativeWidth / appWebviewWidth; webviewHeight = nativeHeight / ratio; webviewWidth = appWebviewWidth; taskbarWebviewHeight = webviewHeight - appWebviewHeight; taskbarWebviewWidth = webviewWidth; taskbarNativeHeight = taskbarWebviewHeight * ratio; taskbarNativeWidth = nativeWidth; appNativeWidth = nativeWidth; appNativeHeight = nativeHeight - taskbarNativeHeight; varStatus(); }

Target:
public PerformTouchAction(WebDriver webDriver) { String methodName = "PerformTouchAction"; mobileDriver = NewDriverProvider.getMobileDriver(); driver = webDriver; JavascriptExecutor js = (JavascriptExecutor) driver; addressbarWebviewHeight = Integer.parseInt(js.executeScript("return $(window).height()").toString()); addressbarWebviewWidth = Integer.parseInt(js.executeScript("return $(window).width()").toString()); waitForFinish(5000, methodName); switchToContext(CONTEXT_NATIVE_APP, methodName); nativeHeight = mobileDriver.manage().window().getSize().height; nativeWidth = mobileDriver.manage().window().getSize().width; int startX = nativeWidth / 2; int startY = nativeHeight - 1; int endX = startX; int endY = nativeHeight / 3; int duration = startY - endY; mobileDriver.swipe(startX, startY, endX, endY, duration); waitForFinish(duration * 3, methodName); switchToContext(CONTEXT_WEBVIEW_1, methodName); js.executeScript("window.scrollTo(0, 0)"); appWebviewHeight = Integer.parseInt(js.executeScript("return $(window).height()").toString()); appWebviewWidth = Integer.parseInt(js.executeScript("return $(window).width()").toString()); loadedPageHeight = Integer.parseInt(js.executeScript("return $(document).height()").toString()); loadedPageWidth = Integer.parseInt(js.executeScript("return $(document).width()").toString()); addressbarWebviewHeight = appWebviewHeight - addressbarWebviewHeight; ratio = nativeWidth / appWebviewWidth; webviewHeight = nativeHeight / ratio; webviewWidth = appWebviewWidth; taskbarWebviewHeight = webviewHeight - appWebviewHeight; taskbarWebviewWidth = webviewWidth; taskbarNativeHeight = taskbarWebviewHeight * ratio; taskbarNativeWidth = nativeWidth; appNativeWidth = nativeWidth; appNativeHeight = nativeHeight - taskbarNativeHeight; addressbarNativeHeight = addressbarWebviewHeight * ratio; addressbarNativeWidth = nativeWidth; }