簡體   English   中英

Nativescript-Dev-Appium 設置

[英]Nativescript-Dev-Appium Setup

我正在嘗試在現有的 nativescript-angular 項目中實現 nativescript-dev-appium,並且在配置插件時遇到了很多麻煩。

模擬器似乎已找到,但在before allafter all掛鈎中運行失敗,因為它似乎沒有設備實例。

walrus:demo-appium niirds$ npm run e2e -- --runType sim.iPhoneX --verbose

> @ e2e /Users/niirds/mobi/demo-appium
> node ./node_modules/nativescript-dev-appium/check-dev-deps.js &&  tsc -p e2e  &&  mocha --opts ./e2e/config/mocha.opts  "--runType" "sim.iPhoneX" "--verbose"



/Users/niirds/mobi/demo-appium/e2e/config/appium.capabilities.json
Capabilities found at: /Users/niirds/mobi/demo-appium/e2e/config/appium.capabilities.json 
Appium will use default automation name
Available applications:  ["platforms/ios/build/emulator/demoappium.app"]
Pick first application:   "platforms/ios/build/emulator/demoappium.app"
Application full path: /Users/niirds/mobi/demo-appium/platforms/ios/build/emulator/demoappium.app 
Found devices:  [ { token: 'C8B1990E-1593-49A8-AA68-C7E5CC2134BB',
    name: 'iPhone X',
    status: 'booted',
    type: 'watch',
    apiLevel: '12.2',
    platform: 'ios',
    config: { density: 3, offsetPixels: 87 } } ]
  1) "before all" hook: start server
  2) "after all" hook: stop server

  0 passing (2s)
  2 failing

  1) "before all" hook: start server:
     TypeError: Cannot read property 'type' of undefined
      at DeviceManager.<anonymous> (node_modules/nativescript-dev-appium/lib/device-manager.js:82:28)
      at Generator.next (<anonymous>)
      at fulfilled (node_modules/nativescript-dev-appium/lib/device-manager.js:4:58)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  2) "after all" hook: stop server:
     TypeError: Cannot read property 'platform' of undefined
      at Function.<anonymous> (node_modules/mobile-devices-controller/lib/device-controller.js:104:24)
      at Generator.next (<anonymous>)
      at /Users/niirds/mobi/demo-appium/node_modules/mobile-devices-controller/lib/device-controller.js:7:71
      at new Promise (<anonymous>)
      at __awaiter (node_modules/mobile-devices-controller/lib/device-controller.js:3:12)
      at Function.uninstallApp (node_modules/mobile-devices-controller/lib/device-controller.js:103:16)
      at Object.<anonymous> (node_modules/nativescript-dev-appium/index.js:85:64)
      at Generator.next (<anonymous>)
      at /Users/niirds/mobi/demo-appium/node_modules/nativescript-dev-appium/index.js:7:71
      at new Promise (<anonymous>)
      at __awaiter (node_modules/nativescript-dev-appium/index.js:3:12)
      at Object.stopServer (node_modules/nativescript-dev-appium/index.js:77:12)
      at Object.<anonymous> (e2e/setup.js:16:37)
      at Generator.next (<anonymous>)
      at /Users/niirds/mobi/demo-appium/e2e/setup.js:7:71
      at new Promise (<anonymous>)
      at __awaiter (e2e/setup.js:3:12)
      at Context.after (e2e/setup.js:15:28)
      at process.topLevelDomainCallback (domain.js:121:23)



npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ e2e: `node ./node_modules/nativescript-dev-appium/check-dev-deps.js &&  tsc -p e2e  &&  mocha --opts ./e2e/config/mocha.opts  "--runType" "sim.iPhoneX" "--verbose"`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

這是安裝提供的模擬器功能:

    "sim.iPhoneX": {
        "platformName": "iOS",
        "platformVersion": "/12*/",
        "deviceName": "iPhone X",
        "noReset": false,
        "fullReset": false,
        "app": ""
    },

我安裝了 xcode 10.2,如果有幫助,這里是 package.json。

{
  "nativescript": {
    "id": "org.nativescript.demoappium",
    "tns-android": {
      "version": "5.3.0"
    },
    "tns-ios": {
      "version": "5.3.0"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\"",
    "e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js &&  tsc -p e2e  &&  mocha --opts ./e2e/config/mocha.opts ",
    "e2e-watch": "tsc -p e2e --watch"
  },
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "nativescript-angular": "~7.2.0",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.3.0",
    "tns-core-modules": "~5.3.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~7.2.0",
    "@nativescript/schematics": "~0.5.0",
    "@ngtools/webpack": "~7.2.0",
    "@types/chai": "~4.1.7",
    "@types/mocha": "~5.2.5",
    "@types/node": "~10.12.18",
    "codelyzer": "~4.5.0",
    "mocha": "~5.2.0",
    "mocha-junit-reporter": "~1.18.0",
    "mocha-multi": "~1.0.1",
    "nativescript-dev-appium": "^5.1.0",
    "nativescript-dev-sass": "~1.7.0",
    "nativescript-dev-typescript": "~0.9.0",
    "nativescript-dev-webpack": "~0.21.0",
    "tslint": "~5.11.0"
  },
  "gitHead": "6ccaee804c71761be1c2f91d0b2dd67c8ba6d2b6",
  "readme": "NativeScript Application"
}

重現步驟: 1. 創建示例 nativescript-angular 應用程序--我在此測試中使用了選項卡導航。 2. 安裝 nativescript-dev-appium: npm i -D nativescript-dev-appium 3. 安裝其他依賴https://docs.nativescript.org/angular/tooling/testing/end-to-end-testing/overview#environment -setup 4. 構建應用程序: tns build <platform> 5. 運行測試:`npm run e2e -- --runType

我一直在嘗試讓它在 iOS 上運行。 任何幫助將不勝感激!

我認為由於某種原因,設備控制器返回的設備類型type: 'watch'不正確。

我建議您將配置更改為:

"sim.iPhoneX": {
    "platformName": "iOS",
    "platformVersion": "12.2",
    "deviceName": "iPhone X",
    "noReset": false,
    "fullReset": false,
    "app": ""
},

或者干脆用--ignoreDeviceController選項試試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM