环境配置: appium1.1,windows 7,HTC one
public void setUp() throws Exception {
//配置 webdriver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platform", "WINDOWS");
capabilities.setCapability("deviceName","HTC");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("appPackage", "com.taobao.taobao");
capabilities.setCapability("appActivity", "com.taobao.tao.homepage.MainActivity3");
//appium 的独特地方,使用自己的 AppiumDriver, 它本身是继承自 WebDriver
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//设置超时
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
driver.swipe(157, 1029, 156, 1, 1);
takeScreenShot(driver);
appium 运行日志:
ERROR: debug: Appium request initiated at /wd/hub/session/616bac0b-bc9c-46e5-bfa9-bd1f2e3cca8f/touch/perform
info: Pushing command to appium work queue: ["swipe",{"startX":157,"startY":1029,"endX":156,"endY":1,"steps":0}]
ERROR: debug: Request received with params: {"actions":[{"action":"press","options":{"y":1029,"x":157}},{"action":"wait","options":{"ms":1}},{"action":"moveTo","options":{"y":1,"x":156}},{"action":"release","options":{}}]}
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"swipe","params":{"startX":157,"startY":1029,"endX":156,"endY":1,"steps":0}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: swipe
info: [BOOTSTRAP] [info] Swiping from [x=157.0, y=1029.0] to [x=156.0, y=1.0] with steps: 0
info: [BOOTSTRAP] [info] Returning result: {"value":"The swipe did not complete successfully","status":13}
info: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"The swipe did not complete successfully"},"sessionId":"616bac0b-bc9c-46e5-bfa9-bd1f2e3cca8f"}
PS:使用 js.executeScript 方法,传入相同的值,倒是可以运行成功。
有小伙伴遇到同样的问题吗?请问怎么解决的,谢谢。