1.怎么换社区头像?
2.WebView 中有 XPath 可以获得指定元素,但是貌似安卓的情况,即便可以获得当前网页的所有元素的 xpath,但是当前页看不到的元素,即便获得,点击后也没有反应。但是 ios 的情况下,通过 xpath,会自动滚动屏幕到该元素。为什么安卓不能,那么我该用什么函数滚动屏幕?是设置问题,还是本来这俩函数就不一样,求大神指导。
问题 1:修改头像在页面右上角,点开昵称里有个个人资料设置,在个人资料设置页面有修改头像
问题 2:滚动操作可以参考这个帖子 http://testerhome.com/topics/1132
@xiaomayi0323 请问 swipe 报错如何解决?
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 log 在上面
@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 真机测的
@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
@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 恩,我想进去应用以后,先向下滑动
@xiaomayi0323 如果把 swipe 函数注释掉,代码可以运行。但是加上 swipe 函数,一运行就直接推出,或者有时候可以向下滑动,但是还是会报错,导致程序退出。
#15 楼 @liu 有可能是 coordinates 和 duration 的问题,你可以看看我搜的这三个页面
https://groups.google.com/forum/#! topic/appium-discuss/isReHWFsZhs
https://groups.google.com/forum/#! msg/appium-discuss/cayM9HWI26E/qUXF8cFhtNcJ
https://github.com/appium/appium/issues/1006
@xiaomayi0323 仔细看了你给的网页,终于解决了问题。swipe 对 android 4.2 可能不兼容,我换了一台 4.3 的机器后,可以正常运行了。
感谢你帮助。