Appium [已解决] Appium Setting.apk 和 Unlock.apk

roicel · 2014年07月28日 · 最后由 lion 回复于 2017年11月13日 · 1970 次阅读

mac 下面使用 appium,每次启动下面的脚本的时候都会安装 Appium Settings 和 Unlock 这两个 apk。
麻烦问一下有没有什么方法不要让它每次都安装?

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platforVersion'] = '4.2'
desired_caps['deviceName'] = '***'
desired_caps['appPackage'] = '***'
desired_caps['appActivity'] = '***'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
time.sleep(5)
buttonNear = driver.find_element_by_xpath('//android.widget.Button[3]')
共收到 13 条回复 时间 点赞

这个没有方法解决吗?

#1 楼 @roicel 没有办法,代码里写死了。每次都会安装。

Android.prototype.start = function (cb, onDie) {
  this.launchCb = cb;
  this.uiautomatorExitCb = onDie;
  logger.info("Starting android appium");

  if (this.adb === null) {
    this.adb = new ADB(this.args);
  }

  if (this.uiautomator === null) {
    this.uiautomator = new UiAutomator(this.adb, this.args);
    this.uiautomator.setExitHandler(this.onUiautomatorExit.bind(this));
  }

  logger.debug("Using fast reset? " + this.args.fastReset);
  async.series([
    this.prepareDevice.bind(this),
    this.packageAndLaunchActivityFromManifest.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), // 这里
    this.pushUnlock.bind(this), // 这里
    this.uiautomator.start.bind(this.uiautomator),
    this.wakeUp.bind(this),
    this.unlockScreen.bind(this),
    this.getDataDir.bind(this),
    this.startApp.bind(this),
    this.initAutoWebview.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));
};

#2 楼 @lihuazhang 哦 学习了 谢啦

#2 楼 @lihuazhang 开始也是感到不解

这块挺坑的。 可以考虑自己加代码优化下。 每次安装挺耗费资源

#2 楼 @lihuazhang
我注释掉这两行代码了

this.pushSettingsApp.bind(this), 
this.pushUnlock.bind(this), 

这样可以不用每次都安装,没有发现什么大的问题出现,但是这样会有什么弊端?时不时的会出现 an element could not be located 是不是这个造成的?

#7 楼 @lihuazhang
那是 desired_caps['noReset'] = True 的原因?

我在改这两个部分之前没有定位不到的问题,改了之后总会出现,把 appium 关掉重启一下又正常了,不解

#8 楼 @xzhan noreset 是说上次测试之后,应用不会重置,还是上次跑完测试时候的样子,。

#9 楼 @lihuazhang 就是说我这一次测试完成,noreset,再跑同一个用例的话就会找不到 element 是么?

#6 楼 @xzhan
问一下这是哪个文件,路径是什么,谢谢

#6 楼 @xzhan
已经解决了
用 cnpm 装的,后来卸载用 exe 安装就知道这个文件了
Appium\node_modules\appium\lib\devices\android\android.js

13楼 已删除

看评论是说修改 andriod.js 文件,可 mac 上我用的客户端,找不到这个文件啊。楼主已解决是找到这个文件的路径了么?求告知

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