#24 楼 @actionwind 你好,能解释一下具体怎么用嘛,最后贴一段示例代码什么的,O(∩_∩) O 谢谢
#9 楼 @chenhengjie123 我已经解决了哈,取巧了一下,把 GUI 下面的指令直接丢过来用 OK 了,没有使用 appium 这个指令,谢谢你的帮助哦
#9 楼 @chenhengjie123 我确定每次启动的都是 SplashActivity。而且我使用 Gui 版本来启动 appium sever 的时候勾选上那个 stop on start 就是没问题的,看日志也是首先获取到的就是 SplashActivity;不勾上的话就和命令行报相同的错误。这个就相当奇怪,我百思不得其解啊
#7 楼 @chenhengjie123 没有解决哦,理论上这个参数应该默认不用加就是对的,但实际上的结果却不一致,所以还不知道怎么弄
@lihuazhang、@seveniruby、@monkey 帮我恢复一下,谢谢
#26 楼 @quqing 就是上面回复你的那段呀,在 server 里面打印出来的
log 如下:
2016-07-20 10:21:12:930 - [HTTP] <-- GET /wd/hub/status - - ms - -
2016-07-20 10:21:12:962 - [debug] [ADB] Waiting for pkg: 'xxxxx' and activity: 'xxxxx.SplashActivity' to be focused
2016-07-20 10:21:12:963 - [debug] [ADB] Possible activities, to be checked: xxxxx.SplashActivity, .SplashActivity, .xxxxx.SplashActivity
2016-07-20 10:21:12:964 - [debug] [ADB] Getting focused package and activity
2016-07-20 10:21:12:965 - [debug] [ADB] Getting connected devices...
2016-07-20 10:21:12:988 - [debug] [ADB] 1 device(s) connected
2016-07-20 10:21:12:989 - [debug] [ADB] Running /Users/cy/Documents/ADT-Eclipse/sdk/platform-tools/adb with args: ["-P",5037,"-s","85GBBM9235WL","shell","dumpsys","window","windows"]
2016-07-20 10:21:13:045 - [debug] [ADB] Found package: 'xxxxx' and activity: '.ui.tab.MainTabActivity'
2016-07-20 10:21:13:046 - [debug] [ADB] Incorrect package and activity. Retrying.
2016-07-20 10:21:13:797 - [debug] [ADB] Getting focused package and activity
2016-07-20 10:21:13:798 - [debug] [ADB] Getting connected devices...
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
// 被测应用存放的目录
File appDir = new File(classpathRoot, CommonData.appPath);
// 被测应用的apk名字
File app = new File(appDir, CommonData.appName);
// 设置DesiredCapabilities信息
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
// 以下两项为了支持中文输入
capabilities.setCapability("unicodeKeyboard", "True");
capabilities.setCapability("resetKeyboard", "True");
capabilities.setCapability("device", "Android");
// 安卓真机的信息,版本5.0.1,魅族MX5
capabilities.setCapability("deviceName", CommonData.deviceName);
capabilities.setCapability(CapabilityType.VERSION,CommonData.deviceVersion);
// 使用的是mac平台
capabilities.setCapability(CapabilityType.PLATFORM, "Mac OS X");
// 设置apk路径
capabilities.setCapability("app", app.getAbsolutePath());
// 应用的主包名
capabilities.setCapability("app-package", CommonData.appPackage);
//
capabilities.setCapability("StopAppOnReset", "True");
capabilities.setCapability("noReset", "True");
driver = new AndroidDriver<WebElement>(new URL(CommonData.serverUrl), capabilities);
我设置了 ‘capabilities.setCapability("StopAppOnReset", "True");’
但是好像没有生效,因为走到最后的 new AndroidDriver 这里的时候就提示错误了,没有等到.SplashActivity 了
#1 楼 @chenhengjie123
勾上的时候,如下
Launching Appium with command: export ANDROID_HOME="/Users/cy/Documents/ADT-Eclipse/sdk"; '/Applications/Appium.app/Contents/Resources/node/bin/node' appium/build/lib/main.js --address "127.0.0.1" --port "4725" --pre-launch --debug-log-spacing --log-timestamp --log-level "debug" --local-timezone --automation-name "Appium" --platform-name "Android" --platform-version "5.0.1" --no-reset --app-pkg ""
不勾选上的时候,如下
Launching Appium with command: export ANDROID_HOME="/Users/cy/Documents/ADT-Eclipse/sdk"; '/Applications/Appium.app/Contents/Resources/node/bin/node' appium/build/lib/main.js --address "127.0.0.1" --port "4725" --pre-launch --debug-log-spacing --log-timestamp --log-level "debug" --local-timezone --automation-name "Appium" --platform-name "Android" --platform-version "5.0.1" --no-reset --dont-stop-app-on-reset --app-pkg ""
就是不勾选的时候多了一个 ‘--dont-stop-app-on-reset’ 的参数,然后我在启动的时候就没有加这个参数,结果就不行
@lihuazhang、@seveniruby、@monkey 帮我恢复一下哦,谢谢
#22 楼 @quqing 我对比了 GUI 版本和我的命令行,就差如图红框处的选项,如果勾上就 OK,不勾上就提示错误的 activity,log 如下:
2016-07-20 10:21:12:930 - [HTTP] <-- GET /wd/hub/status - - ms - -
2016-07-20 10:21:12:962 - [debug] [ADB] Waiting for pkg: 'xxxxx' and activity: 'xxxxx.SplashActivity' to be focused
2016-07-20 10:21:12:963 - [debug] [ADB] Possible activities, to be checked: xxxxx.SplashActivity, .SplashActivity, .xxxxx.SplashActivity
2016-07-20 10:21:12:964 - [debug] [ADB] Getting focused package and activity
2016-07-20 10:21:12:965 - [debug] [ADB] Getting connected devices...
2016-07-20 10:21:12:988 - [debug] [ADB] 1 device(s) connected
2016-07-20 10:21:12:989 - [debug] [ADB] Running /Users/cy/Documents/ADT-Eclipse/sdk/platform-tools/adb with args: ["-P",5037,"-s","85GBBM9235WL","shell","dumpsys","window","windows"]
2016-07-20 10:21:13:045 - [debug] [ADB] Found package: 'xxxxx' and activity: '.ui.tab.MainTabActivity'
2016-07-20 10:21:13:046 - [debug] [ADB] Incorrect package and activity. Retrying.
2016-07-20 10:21:13:797 - [debug] [ADB] Getting focused package and activity
2016-07-20 10:21:13:798 - [debug] [ADB] Getting connected devices...
请问你知道这个对应的命令行参数是什么么?我在代码里面设置了
capabilities.setCapability("StopAppOnReset", "True");
但是好像没有效果