hi,
Swipe not working with co ordinates and press pointoption.
Using java-client-7.0.0
Can you please help me.
Please find the code and log below.
public class Unit3 {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File appDir = new File("src");
File appName = new File(appDir, "ApiDemos-debug.apk");
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus6");
capability.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
capability.setCapability(MobileCapabilityType.APP, appName.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),capability);
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
driver.findElementByXPath("//android.widget.TextView[@text='Views']").click();
boolean flag = true;
do
{
TouchAction touch = new TouchAction(driver);
Dimension size = driver.manage().window().getSize();
int startx = size.getWidth()/2;
int endx = size.getWidth()/2;
int starty = (int)(size.getHeight()* 0.80);
int endy = (int)(size.getHeight()* 0.10);
touch.press(PointOption.point(startx, starty)).waitAction().moveTo(PointOption.point(endx, endy)).release().perform();
List<AndroidElement> ls = driver.findElementsByClassName("android.widget.TextView");
for(int i=0;i<ls.size();i++)
{
if(ls.get(i).getText().contains("Seek")){
touch.tap(tapOptions().withElement(element(ls.get(i)))).perform();
flag=false;
break;
}
}
}while(flag=true);
}
}
[HTTP] <-- GET /wd/hub/session/353eb1f7-d777-4c51-b723-a7685d8eec19/window/rect 200 37 ms - 50
[HTTP]
[HTTP] --> POST /wd/hub/session/353eb1f7-d777-4c51-b723-a7685d8eec19/touch/perform
[HTTP] {“actions”:[{“action”:“press”,“options”:{“x”:720,“y”:1913}},{“action”:“wait”,“options”:{}},{“action”:“moveTo”,“options”:{“x”:720,“y”:239}},{“action”:“release”,“options”:{}}]}
[debug] [W3C (353eb1f7)] Calling AppiumDriver.performTouch() with args: [[{“action”:“press”,“options”:{“x”:720,“y”:1913}},{“action”:“wait”,“options”:{}},{“action”:“moveTo”,“options”:{“x”:720,“y”:239}},{“action”:“release”,“options”:{}}],“353eb1f7-d777-4c51-b723-a7685d8eec19”]
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“swipe”,“params”:{“startX”:720,“startY”:1913,“endX”:720,“endY”:239,“steps”:22}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getDeviceSize
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:{“height”:2392,“width”:1440}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“swipe”,“params”:{“startX”:720,“startY”:1913,“endX”:720,“endY”:239,“steps”:22}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: swipe
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[debug] [W3C (353eb1f7)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: The swipe did not complete successfully
[debug] [W3C (353eb1f7)] at errorFromMJSONWPStatusCode (C:\Users\sures\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:789:10)
[debug] [W3C (353eb1f7)] at Socket.socketClient.on.data (C:\Users\sures\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\bootstrap.js:139:18)
[debug] [W3C (353eb1f7)] at Socket.emit (events.js:189:13)
[debug] [W3C (353eb1f7)] at addChunk (_stream_readable.js:284:12)
[debug] [W3C (353eb1f7)] at readableAddChunk (_stream_readable.js:261:13)
[debug] [W3C (353eb1f7)] at Socket.Readable.push (_stream_readable.js:220:10)
[debug] [W3C (353eb1f7)] at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
[HTTP] <-- POST /wd/hub/session/353eb1f7-d777-4c51-b723-a7685d8eec19/touch/perform 500 76 ms - 927
[HTTP]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1440,2392]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1440,2392]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=720.0, y=1913.0] to [x=720.0, y=239.0] with steps: 22[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:13,“value”:“The swipe did not complete successfully”}
[debug] [AndroidBootstrap] Emitting alert message…
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message