@xiaomayi0323 仔细看了你给的网页,终于解决了问题。swipe 对 android 4.2 可能不兼容,我换了一台 4.3 的机器后,可以正常运行了。
感谢你帮助。
@xiaomayi0323 如果把 swipe 函数注释掉,代码可以运行。但是加上 swipe 函数,一运行就直接推出,或者有时候可以向下滑动,但是还是会报错,导致程序退出。
@xiaomayi0323 恩,我想进去应用以后,先向下滑动
@xiaomayi0323
@Test
public void netnews() throws InterruptedException{
driver.swipe(100,800,100,200,3000);
List text = driver.findElement(By.className("android.widget.ListView")).findElements(By.className("android.widget.LinearLayout"));
text.get(5).click();
Thread.sleep(6000);
driver.sendKeyEvent(4);
WebElement text2 = driver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.TextView\").text(\"娱乐\")");
text2.click();
Thread.sleep(1000);
driver.swipe(100,800,100,200,3000);
List text3 = driver.findElement(By.className("android.widget.ListView")).findElements(By.className("android.widget.LinearLayout"));
text3.get(5).click();
Thread.sleep(6000);
}
@xiaomayi0323 手机信息:
info: <-- GET /wd/hub/session/64d0aa9c-71a0-43e1-bccf-065ccccebc72 200 1.080 ms - 641 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.2","platformName":"Android","deviceName":"ZTE","browserName":"","appActivity":"com.netease.nr.biz.ad.AdActivity","appPackage":"com.netease.newsreader.activity"},"platformName":"Android","deviceName":"ZTE","appActivity":"com.netease.nr.biz.ad.AdActivity","appPackage":"com.netease.newsreader.activity"},"sessionId":"64d0aa9c-71a0-43e1-bccf-065ccccebc72"}
@xiaomayi0323 真机测的
@xiaomayi0323
info: --> POST /wd/hub/session/64d0aa9c-71a0-43e1-bccf-065ccccebc72/touch/perform {"actions":[{"action":"press","options":{"y":800,"x":100}},{"action":"wait","options":{"ms":3000}},{"action":"moveTo","options":{"y":200,"x":100}},{"action":"release","options":{}}]}
debug: Pushing command to appium work queue: ["swipe",{"startX":100,"startY":800,"endX":100,"endY":200,"steps":84}]
debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"swipe","params":{"startX":100,"startY":800,"endX":100,"endY":200,"steps":84}}
debug: [BOOTSTRAP] [debug] Got command of type ACTION
debug: [BOOTSTRAP] [debug] Got command action: swipe
debug: [BOOTSTRAP] [debug] Swiping from [x=100.0, y=800.0] to [x=100.0, y=200.0] with steps: 84
debug: [BOOTSTRAP] [debug] Returning result: {"value":"The swipe did not complete successfully","status":13}
debug: 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":"64d0aa9c-71a0-43e1-bccf-065ccccebc72"}
info: <-- POST /wd/hub/session/64d0aa9c-71a0-43e1-bccf-065ccccebc72/touch/perform 500 2454.481 ms - 208
info: --> DELETE /wd/hub/session/64d0aa9c-71a0-43e1-bccf-065ccccebc72 {}
info: Shutting down appium session
@xiaomayi0323 log 在上面
debug: [BOOTSTRAP] [debug] Swiping from [x=100.0, y=800.0] to [x=100.0, y=200.0] with steps: 840
debug: [BOOTSTRAP] [debug] Returning result: {"value":"The swipe did not complete successfully","status":13}
debug: 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":"d3b8b595-2b60-4f13-a5c2-c99106ac403a"}
@xiaomayi0323 请问 swipe 报错如何解决?