【问题标题】:Protractor script fails to execute on the android device量角器脚本无法在 android 设备上执行
【发布时间】:2018-01-04 02:54:31
【问题描述】:

我的量角器配置文件如下所示:

var myHelper = require("./myHelper.js");
exports.config = {

  seleniumAddress: 'http://localhost:4723/wd/hub', of appium url
  chromeDriver: 'C:/appium/chromedriver',

  specs: ['tests/file1.js'],
  jasmineNodeOpts: {
    defaultTimeoutInterval: 180000,
  },
  prefs: {
      'profile.managed_default_content_settings.geolocation': 1,
      'profile.default_content_settings.popups':0
    },
  multiCapabilities: [
    {
      browserName: 'chrome',
      platformName: 'Android',
      platformVersion: '7.0',
      deviceName: 'ce10160a3538442705',
      'newCommandTimeout' : 120,

      'chromeOptions': {

        'args': ["--use-fake-ui-for-media-stream", '--use-fake-device-for-media-stream', '--disable-web-security','--start-maximized','--full-reset']
      },
    }
  ],

  onPrepare: function() {

    global.browsers = {
      a: (()=>{
        browser.ignoreSynchronization = true;
        return browser;
      })(),
      b: ()=> {
        var br = browser.forkNewDriverInstance(false, false);
        br.ignoreSynchronization = true;
        return br;
      },
      myHelper: myHelper
    };
  },
};

& 使用以下命令运行 appium:

appium -p 4723 -bp 4728 -U "ce10160a3538442705" --chromedriver-port 9516

当我运行 protractor conf.js 时,android 设备被解锁,但 chrome 浏览器没有启动,它再次自行解锁。

日志:

[AndroidDriver] Using app unlock, this is going to be deprecated!
[AndroidDriver] Unlocking screen
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","am","force-stop","io.appium.unlock"]
[debug] [ADB] Device API level: 24
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","am","start","-W","-n","io.appium.unlock/.Unlock","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[debug] [ADB] Device API level: 24
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","am","start","-W","-n","io.appium.unlock/.Unlock","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","dumpsys","window"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","dumpsys","window"]
[debug] [AndroidDriver] Shutting down Android driver
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 449.159
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce10160a3538442705","shell","am","force-stop","io.appium.unlock"]
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Screen did not unlock successfully, retrying
    at Object.callee$1$0$ (../../lib/android-helpers.js:453:13)
    at tryCatch (C:\Users\xxxx\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\xxxx\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\xxxx\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\xxxx\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:109:7)
[HTTP] <-- POST /wd/hub/session 500 463534 ms - 181

【问题讨论】:

  • 你有错误日志吗?
  • 请查找附件日志。谢谢!

标签: javascript protractor appium


【解决方案1】:

我在这里发现了问题。设备在 30 秒后设置为自动锁定,因此每当 appium 启动大约 30 秒时,它就会再次尝试解锁设备。 我想知道一起禁用自动锁定是否是一个不错的选择。

【讨论】:

    猜你喜欢
    • 2016-06-27
    • 2015-02-06
    • 1970-01-01
    • 2017-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多