appium 【已解决】Android,每次启动手机中都会安装Appium settings和Unclock的方法
环境介绍:
1、appium版本:1.4.16.1
2、真机运行
实现结果:
运行appium第一次运行则安装Appium settings和Unclock的apk,再次之后的运行则无需手动卸载,再次安装。
问题描述:
第一次:Android手机运行appium,自动安装Appium settings和Unclock的apk,
第二次:第一次运行完毕,若不手动删除已经安装的Appium settings和Unclock,将会提示报错信息如下,提示:Appium settings和Unclock不是第一次安装,因此必须每次运行appium脚本,都需要手动删除此2个apk,重新运行则不会报错。
WebDriverException: Message: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\AutoTest\adt-bundle-windows-x86-20140702\sdk\platform-tools\adb.exe -s GWY0216A22013956 install "D:\AutoTest\appium\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""
Failed to install D:\AutoTest\appium\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
)
根据以上报错信息,可以看到Appium settings和Unclock的安装路径。
apk作用说明:
1、Appium settings:用于设置网络状态
2、Unclock:用于自动解锁(使用场景:手机是滑动锁屏的情况下,则会自动解锁并启动apk,注意:图案锁屏与数字锁则不可以哦,只能是滑动锁屏)
解决方法:
1、需要手动去修改appium安装路径下的android.js文件,来实现运行首次安装Appium settings和Unclock,之后的运行则无需再次卸载的操作。
2、android.js的存放路径:D:\Auto Test\appium\Appium\node_modules\appium\lib\devices\android\android.js,说明:D:\Auto Test\appium\为本人的appium存放路径。
3、android.js文件中找到如下代码
... Android.prototype.start = function (cb, onDie) { this.launchCb = cb; this.uiautomatorExitCb = onDie; logger.info("Starting android appium"); async.series([ this.initJavaVersion.bind(this), this.initAdb.bind(this), this.packageAndLaunchActivityFromManifest.bind(this), this.initUiautomator.bind(this), this.prepareDevice.bind(this), this.checkApiLevel.bind(this), this.pushStrings.bind(this), this.processFromManifest.bind(this), this.uninstallApp.bind(this), this.installAppForTest.bind(this), this.forwardPort.bind(this), this.pushAppium.bind(this), this.initUnicode.bind(this), //this.pushSettingsApp.bind(this), #手动注释此2行代码,即可解决问题 //this.pushUnlock.bind(this), function (cb) {this.uiautomator.start(cb);}.bind(this), this.wakeUp.bind(this), this.unlock.bind(this), this.getDataDir.bind(this), this.setupCompressedLayoutHierarchy.bind(this), this.startAppUnderTest.bind(this), this.initAutoWebview.bind(this), this.setActualCapabilities.bind(this) ], function (err) { if (err) { this.shutdown(function () { this.launchCb(err); }.bind(this)); } else { this.didLaunch = true; this.launchCb(null, this.proxySessionId); } }.bind(this)); };
欢迎加入群一起学习:
1.作者:Syw 2.出处:http://www.cnblogs.com/syw20170419/ 3.本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 4.如果文中有什么错误,欢迎指出。以免更多的人被误导。 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?