Appium (新手求助)**APPIUM 不执行用例 **(请各位大神进来看一下,指点一下迷津)

LiDaihong · 2017年04月11日 · 最后由 马家爵 回复于 2017年05月20日 · 69 次阅读

我在尝试使用 appium 的时候编写了一个简单的脚本,但是出现问题是:
appium 每次执行就只打开我手机上的 app,然后就结束了,没有执行我在脚本内编写的用例代码,我查看运行日志,日志中只是提醒没有接收到新的会话,等待新会话实践超多 60s,结束会话,杀掉 app 进程
在 eclipse 中通过查看发现这样的情况:
1.脚本无错误
2.测试结果从一开始便是由红色 x 标记
不明白为什么,请大神们指点一下迷津,谢谢!下面附上一些我写的脚本,还有 eclipse 中的结果截图,和 appium 运行日志中的一些结果提醒。
脚本如下
public void myteststart() throws MalformedURLException {
File classpathRoot= new File(System.getProperty("user.dir"));
File appDir= new File(classpathRoot, "res/app");
File app = new File(appDir, "lzvtc.apk");
DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("deviceName","M5 Note");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("app", "C:/Users/Administrator/workspace/appiumdemo/res/app/lzvtc.apk");
capabilities.setCapability("appPackage", "com.lantu.MobileCampus.lzvtc");
capabilities.setCapability("appActivity", "com.lantu.MobileCampus.lzvtc.MainActivity");
driver= new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@AfterClass

public void afterClass()
{

driver.quit();
}
public void my_test2() throws InterruptedException {

((WebElement) driver.findElementsByAccessibilityId("立即体验")).click();

((WebElement) driver.findElementsByAccessibilityId("请输入登录账号")).sendKeys("xy");

((WebElement) driver.findElementsByAccessibilityId("登陆")).click();

driver.findElement(By.xpath("//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.android.webkit.WebView/android.widget.android.view.View/android.widget.android.view.View[3]")).sendKeys("xy");

((WebElement) driver.findElementsByAccessibilityId("基础服务")).click();

((WebElement) driver.findElementsByAccessibilityId("新闻公告")).click();

}
截图如下

运行部分日志如下
* info: [debug] Didn't get a new command in 60 secs, shutting down...*

info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: E:\android_sdk\platform-tools\adb.exe -s 621QECQ83QJ4Q shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
info: [debug] [UIAUTOMATOR STDOUT] close [socket][/127.0.0.1:4724]
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 63.091
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in

共收到 5 条回复 时间 点赞

大哥,你是不是要看看 换种发帖方式? 你发的贴都是 0 回复。

您好,请问您的问题解决了吗?我也遇到了同样的问题。

用的 junit 还是 testng??

1、百度了下说需要更新 selenium 版本
2、你的代码看着很乱,比如定义了 app 这个 file 变量,最后用的是一个 String 字符串。。

我想起了功夫里的一句台词 老鬼 你还是说中文吧 我们听不懂啊!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册