0

我目前正在尝试为由 Android 提供支持的移动应用程序编写一些自动测试,但一开始我就遇到了一些奇怪的错误。

当我尝试使用 WDIO Appium (wdio-appium-service) 连接到我的应用程序时,我得到以下信息:

    A service failed in the 'onPrepare' hook
Error: Appium exited before timeout (Exit code: 1)
    at ChildProcess.exitCallback (D:\Workspace\asystent-tests\node_modules\wdio-appium-service\build\launcher.js:94:28)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

Continue...
ERROR: Cannot find module 'D:\Workspace\asystent-tests\features\step-definitions'
62210157hy8265j0et0.android.6
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.resolve (internal/module.js:18:19)
    at D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\build\adapter.js:226:46
    at Array.forEach (<anonymous>)
    at CucumberAdapter.loadSpecFiles (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\build\adapter.js:218:39)
    at CucumberAdapter._callee$ (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\build\adapter.js:129:38)
    at tryCatch (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\regenerator-runtime\runtime.js:65:40)
    at Generator.invoke [as _invoke] (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\regenerator-runtime\runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\regenerator-runtime\runtime.js:117:21)
    at step (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\babel-runtime\helpers\asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (D:\Workspace\asystent-tests\node_modules\core-js\library\modules\_export.js:35:28)
    at CucumberAdapter.<anonymous> (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\node_modules\babel-runtime\helpers\asyncToGenerator.js:14:12)
    at CucumberAdapter.run (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\build\adapter.js:193:29)
    at Object._callee2$ (D:\Workspace\asystent-tests\node_modules\wdio-cucumber-framework\build\adapter.js:328:40)

Appium 服务器控制台:

[Appium] Welcome to Appium v1.7.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"appiumVersion":"1.7.2","appWaitActivity":"com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity","appActivity":"com.so99.ui.login.LoginActivity","appPackage":"com.so99.debug","platformVersion":"6","platformName":"Android","deviceName":"62210157HY8265J0ET0","requestOrigins":{"url":"http://webdriver.io","version":"4.10.1","name":"webdriverio"}}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"appiumVersion":"1.7.2","appWaitActivity":"com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity","appActivity":"com.so99.ui.login.LoginActivity","appPackage":"com.so99.debug","platformVersion":"6","platformName":"Android","deviceName":"62210157HY8265J0ET0","requestOrigins":{"url":"http://webdriver.io","version":"4.10.1","name":"webdriverio"}},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1516710830422 (13:33:50 GMT+0100 (Środkowoeuropejski czas stand.))
[Appium] Creating new AndroidDriver (v1.37.0) session
[Appium] Capabilities:
[Appium]   javascriptEnabled: true
[Appium]   locationContextEnabled: true
[Appium]   handlesAlerts: true
[Appium]   rotatable: true
[Appium]   appiumVersion: 1.7.2
[Appium]   appWaitActivity: com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity
[Appium]   appActivity: com.so99.ui.login.LoginActivity
[Appium]   appPackage: com.so99.debug
[Appium]   platformVersion: 6
[Appium]   platformName: Android
[Appium]   deviceName: 62210157HY8265J0ET0
[Appium]   requestOrigins: {
[Appium]     url: http://webdriver.io
[Appium]     version: 4.10.1
[Appium]     name: webdriverio
[Appium]   }
[BaseDriver] The following capabilities were provided, but are not recognized by appium: javascriptEnabled, locationContextEnabled, handlesAlerts, rotatable, appiumVersion, requestOrigins.
[BaseDriver] Session created with session id: f35ac58f-a1d0-4be3-9616-8f2b3476a792
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 9.0.1
[ADB] Checking whether adb is present
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '6'
[ADB] Setting device id to 62210157HY8265J0ET0
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 6.0
[AndroidDriver] Using device: 62210157HY8265J0ET0
[ADB] Checking whether adb is present
[ADB] Setting device id to 62210157HY8265J0ET0
[AndroidDriver] App file was not listed, instead we're going to run com.so99.debug directly on the device
[AndroidDriver] Checking whether package is present on the device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","list","packages","com.so99.debug"]
[AndroidDriver] Starting Android session
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","wait-for-device"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","echo","ping"]
[AndroidDriver] setDeviceLanguageCountry requires language or country.
[AndroidDriver] Got language: 'undefined' and country: 'undefined'
[Logcat] Starting logcat capture
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","list","packages","io.appium.settings"]
[ADB] App is installed
[ADB] Getting package info for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","dumpsys","package","io.appium.settings"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\Wiktor\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe
[ADB] The installed 'io.appium.settings' package does not require upgrade (5 >= 5)
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","getprop","ro.build.version.sdk"]
[ADB] Current device property 'ro.build.version.sdk': 23
[ADB] Device API level: 23
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","dumpsys","package","io.appium.settings"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","dump","io.appium.settings"]
[ADB] Got the following command chunks to execute: pm,grant,io.appium.settings,android.permission.WRITE_SETTINGS,;,pm,grant,io.appium.settings,android.permission.ACCESS_MOCK_LOCATION,;
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","ps"]
[ADB] Device API level: 23
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","appops","set","io.appium.settings","android:mock_location","allow"]
[AndroidDriver] Pushing unlock helper app to device...
[ADB] Getting install status for io.appium.unlock
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","list","packages","io.appium.unlock"]
[ADB] App is installed
[ADB] Getting package info for io.appium.unlock
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","dumpsys","package","io.appium.unlock"]
[ADB] Checking whether aapt is present
[ADB] The installed 'io.appium.unlock' package does not require upgrade (2 >= 2)
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 6.0
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","wm","size"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","getprop","ro.product.model"]
[ADB] Current device property 'ro.product.model': Lenovo TB3-850M
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","getprop","ro.product.manufacturer"]
[ADB] Current device property 'ro.product.manufacturer': LENOVO
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
[AndroidDriver] Running fast reset (stop and clear)
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","am","force-stop","com.so99.debug"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","pm","clear","com.so99.debug"]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","forward","tcp:4724","tcp:4724"]
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","push","C:\\Users\\Wiktor\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-bootstrap\\bootstrap\\bin\\AppiumBootstrap.jar","/data/local/tmp/"]
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.so99.debug","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Device API level: 23
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","am","start","-W","-n","com.so99.debug/com.so99.ui.login.LoginActivity","-S"]
[ADB] Waiting up to 20000ms for activity matching pkg: 'com.so99.debug' and activity: 'com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity' to be focused
[ADB] Possible activities, to be checked: 'com.so99.ui.login.LoginActivity', 'com.so99.debug.ui.splash.SplashActivity'
[ADB] Getting focused package and activity
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","dumpsys","window","windows"]
[ADB] Found package: 'com.so99.debug' and fully qualified activity name : 'com.so99.ui.login.LoginActivity'
[Appium] New AndroidDriver session created successfully, session f35ac58f-a1d0-4be3-9616-8f2b3476a792 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1516710859036 (13:34:19 GMT+0100 (Środkowoeuropejski czas stand.))
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":true,"warnings":{},"desired":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"appiumVersion":"1.7.2","appWaitActivity":"com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity","appActivity":"com.so99.ui.login.LoginActivity","appPackage":"com.so99.debug","platformVersion":"6","platformName":"Android","deviceName":"62210157HY8265J0ET0","requestOrigins":{"url":"http://webdriver.io","version":"4.10.1","name":"webdriverio"}},"handlesAlerts":true,"rotatable":true,"appiumVersion":"1.7.2","appWaitActivity":"com.so99.ui.login.LoginActivity,.ui.splash.SplashActivity","appActivity":"com.so99.ui.login.LoginActivity","appPackage":"com.so99.debug","platformVersion":"6.0","platformName":"Android","deviceName":"62210157HY8265J0ET0","requestOrigins":{"url":"http://webdriver.io","version":"4.10.1","name"...
[HTTP] <-- POST /wd/hub/session 200 28616 ms - 1236 
[HTTP] --> DELETE /wd/hub/session/f35ac58f-a1d0-4be3-9616-8f2b3476a792 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["f35ac58f-a1d0-4be3-9616-8f2b3476a792"]
[BaseDriver] Event 'quitSessionRequested' logged at 1516710859061 (13:34:19 GMT+0100 (Środkowoeuropejski czas stand.))
[Appium] Removing session f35ac58f-a1d0-4be3-9616-8f2b3476a792 from our master session list
[AndroidDriver] Shutting down Android driver
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","am","force-stop","com.so99.debug"]
[ADB] Pressing the HOME button
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","input","keyevent",3]
[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
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'C:\Users\Wiktor\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","62210157HY8265J0ET0","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture

项目依赖:

  "dependencies": {
    "appium": "^1.7.2",
    "cucumber": "3.2.1",
    "webdriverio": "^4.10.1"
  },
  "devDependencies": {
    "wdio-appium-service": "^0.2.3",
    "wdio-cucumber-framework": "^1.0.3",
    "wdio-dot-reporter": "0.0.9"
  }

cucumberOpts 是默认的,包括require: ['./features/step-definitions']

我在 features/step-definitions 和 features 目录下使用 .feature 扩展了我的步骤

4

0 回答 0