我在尝试执行“缩放”时遇到此错误。使用MultiTouchAction在Google地图元素中执行操作:
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"Unable to perform multi pointer gesture","status":13}
有人知道发生了什么以及如何解决它,它可能真的有用吗? 感谢
我的代码:
try{
WebElement map = Helper.waitVisibilityOfElement(By.xpath(//android.view.View[@content-desc='Google Map']));
WebElement carousel = Helper.waitVisibilityOfElement(By.id(MapScreenElements.carouselId));
int middleX = (int) (map.getLocation().getX()+map.getSize().width*0.5);
int middleY = (int) (map.getLocation().getY()+(map.getSize().height-carousel.getSize().height)*0.5);
int topRightX = (int) (map.getLocation().getX()+map.getSize().width);
int topRightY = map.getLocation().getY();
int bottomLeftX = map.getLocation().getX();
int bottomLeftY = (int) (map.getLocation().getY()+(map.getSize().height
carousel.getSize().height));
TouchAction action0 = new TouchAction(driver).longPress(topRightX,topRightY).moveTo(middleX, middleY).waitAction(500).release();
TouchAction action1 = new TouchAction(driver).longPress(bottomLeftX,bottomLeftY).moveTo(middleX, middleY).waitAction(500).release();
MultiTouchAction zoomIn = new MultiTouchAction(driver);
zoomIn.add(action0);
zoomIn.add(action1);
zoomIn.perform();
}catch(Exception e){
...
}
我的配置:
MAC OS X ElCaptain
Java8
Appium服务器1.5.3
Appium客户端4.1.2
Real Device S4- android 4.4.4< => API 19
更多Appium服务器日志:
[HTTP] <-- POST /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element 200 35 ms - 88
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/displayed {}
[MJSONWP] Calling AppiumDriver.elementDisplayed() with args: ["24","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action"
,"action":"element:getAttribute","params":{"attribute":"displayed","elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getAttribute","params":{"attribute":"displayed","elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getAttribute
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"true","status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.elementDisplayed() result: true
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/displayed 200 32 ms - 76
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 47 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":1677,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":1677,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size 200 42 ms - 100
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 33 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRA
P LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":1677,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":1677,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size 200 32 ms - 100
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["24","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":360,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":360,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/size 200 30 ms - 99
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 43 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":1677,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":1677,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size 200 63 ms - 100
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[debug] [AndroidBootstrap] Received command result from bootstrap
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd
/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 40 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 43 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location {}
[MJSONWP] Calling AppiumDriver.getLocation() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"y":243,"x":0},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getLocation() result: {"y":243,"x":0}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/location 200 34 ms - 87
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["23","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"23"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":1677,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":1677,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/23/size 200 31 ms - 100
[HTTP] --> GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/size {}
[MJSONWP] Calling AppiumDriver.getSize() with args: ["24","0b54fe8b-1222-419b-b...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getSize","params":{"elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"24"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"height":360,"width":1080},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.getSize() result: {"height":360,"width":1080}
[HTTP] <-- GET /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/element/24/size 200 31 ms - 99
[HTTP] --> POST /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/touch/multi/perform {"actions":[[{"action":"longPress","options":{"x":1080,"y":243}},{"action":"moveTo","options":{"x":540,"y":901}},{"action":"wait","options":{"ms":500}
},{"action":"release","options":{}}],[{"action":"longPress","options":{"x":0,"y":1560}},{"action":"moveTo","options":{"x":540,"y":901}},{"action":"wait","options":{"ms":500}},{"action":"release","options":{}}]]}
[MJSONWP] Calling AppiumDriver.performMultiAction() with args: [[[{"action":"longPress","o...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"performMultiPointerGesture","params":{"actions":[[{"action":"longPress","time":0.005,"touch":{"x":1080,"y":243}},{"action":"moveTo","time":0.01,"touch":{"x":1620,"y":1144}},{"action":"wait","time":0.51,"touch":{"ms":500,"x":1620,"y":1144}}],[{"action":"longPress","time":0.005,"touch":{"x":0,"y":1560}},{"action":"moveTo","time":0.01,"touch":{"x":540,"y":2461}},{"action":"wait","time":0.51,"touch":{"ms":500,"x":540,"y":2461}}]]}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"performMultiPointerGesture","params":{"actions":[[{"action":"longPress","time":0.005,"touch":{"x":1080,"y":243}},{"action":"moveTo","time":0.01,"touch":{"x":1620,"y":1144}},{"action":"wait","time":0.51,"touch":{"ms":500,"x":1620,"y":1144}}],[{"action":"longPress","time":0.005,"touch":{"x":0,"y":1560}},{"action":"moveTo","time":0.01,"touch":{"x":540,"y":2461}},{"action":"wait","time":0.51,"touch":{"ms":500,"x":540,"y":2461}}]]}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: performMultiPointerGesture
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"Unable to perform multi pointer gesture","status":13}
[debug] [AndroidBootstrap] Received command result from bootstrap
[HTTP] <-- POST /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b/touch/multi/perform 500 711 ms - 154
[HTTP] --> DELETE /wd/hub/session/0b54fe8b-1222-419b-bb65-bdc708b2238b {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["0b54fe8b-1222-419b-bb65-b...
感谢您的帮助
答案 0 :(得分:0)
为了放大,我使用如下,它工作正常:
//zoom in the image
MultiTouchAction multiTouch = new MultiTouchAction(driver);
TouchAction action0 = new TouchAction(driver).press(xpos1, ypos1).moveTo(-45,-45).release();
TouchAction action1 = new TouchAction(driver).press(xpos2, ypos2).moveTo(45,45).release();
multiTouch.add(action0).add(action1).perform();
//for zoom in, point used in moveTo() is same but opposite direction
在您的代码中,您使用长按,如果您想使用长按,请使用如下所示:
action1.longPress(topRightX,topRightY).waitAction(3000).moveTo(middleX,middleY).release();
//waitAction is used after long press as it takes some time.
希望这会对你有所帮助。