macacajs / NoSmoke

A cross platform UI crawler which scans view trees then generate and execute UI test cases.
https://macacajs.github.io/NoSmoke
MIT License
198 stars 57 forks source link

用nosmoke 测试自带的android demo 跑不通,报错!另外想问下YML 配置文件的详细文档 #26

Closed qileilove closed 6 years ago

qileilove commented 6 years ago

运行环境:macbook pro node 版本 8.5.0 用的android模拟器

server端报错


*************************************
*  version 1.0.35 is outdate        *
*  run: npm i -g macaca-cli@2.0.10  *
*************************************

>> index.js:30:12 [master] pid:3333 webdriver server start with config:
 { port: 3456,
  verbose: true,
  always: true,
  ip: '10.205.20.20',
  host: 'CNlqi-3.local',
  loaded_time: '2017-10-12 13:13:13' }
>> middlewares.js:30:10 [master] pid:3333 base middlewares attached
>> router.js:118:10 [master] pid:3333 router set
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
>> webdriver sdk launched
>> responseHandler.js:24:12 [master] pid:3333 Recieve HTTP Request from Client: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"platformName":"android","deviceName":"192.168.59.101:5555","isWaitActivity":true,"app":"https://npmcdn.com/android-app-bootstrap@latest/android_app_bootstrap/build/outputs/apk/android_app_bootstrap-debug.apk"}}
>> session.js:60:10 [master] pid:3333 Creating session, sessionId: b62b131b-6b86-47d9-b21b-303c9e1dcb6c.
>> responseHandler.js:63:12 [master] pid:3333 Send Error Respone to Client: Error: Server responded with status code 404:
Cannot find module "/android_app_bootstrap/build/outputs" in package android-app-bootstrap@1.0.7
>> responseHandler.js:69:14 [master] pid:3333 Error: Server responded with status code 404:
Cannot find module "/android_app_bootstrap/build/outputs" in package android-app-bootstrap@1.0.7
    at Response.getBody (/usr/local/lib/node_modules/macaca-cli/node_modules/http-response-object/index.js:34:15)
    at downloadWithCache (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/common/helper.js:156:20)
    at Object._.configApp (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/common/helper.js:188:15)
    at Object.createDevice (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/server/controllers/session.js:26:18)
    at createDevice.next (<anonymous>)
    at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:65:19)
    at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
    at Promise (<anonymous>)
    at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
    at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:3333) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.

客户端报错


> nosmoke@0.1.0 dev /Users/lqi/Documents/lqi/work/test/appium/macacatest/NoSmoke
> nodemon ./bin/nosmoke -s

[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/nosmoke -s`
udid: undefined
>> NoSmoke start at: http://10.205.20.20:5678
----> silent mode <-------
  <-- GET /
{ stats:
   { suites: 0,
     tests: 0,
     passes: 3,
     pending: 0,
     failures: 0,
     start: 2017-10-12T05:13:16.662Z,
     passPercent: 50,
     pendingPercent: 0,
     other: 0,
     hasOther: false,
     skipped: 1,
     hasSkipped: true,
     duration: 14523,
     end: 2017-10-12T05:13:16.662Z },
  suites:
   { title: '',
     ctx: {},
     suites: [],
     tests: [],
     pending: [],
     _beforeEach: [],
     _beforeAll: [],
     _afterEach: [],
     _afterAll: [],
     root: true,
     _timeout: 2000,
     _enableTimeouts: true,
     _slow: 75,
     _retries: -1,
     delayed: false,
     _events: { 'pre-require': [] },
     _eventsCount: 1,
     uuid: 'xxxxxxxxxxx',
     fullFile: '',
     file: '',
     passes: [],
     failures: [],
     skipped: [],
     totalTests: 0,
     totalPasses: 0,
     totalFailures: 0,
     totalPending: 0,
     totalSkipped: 0,
     duration: 0,
     _totalTime: 14523 },
  current:
   { image: 'https://macacajs.github.io/macaca-logo/svg/monkey.svg',
     list: [ [Object], [Object], [Object] ] } } { name: 'macaca-reporter',
  fileName: 'index.html',
  assetsInline: true,
  dataAttr: 'data-output',
  configAttr: 'config-output',
  distDir: '/Users/lqi/Documents/lqi/work/test/appium/macacatest/NoSmoke',
  socket: { server: 'http://10.205.20.20:56788' } }
>> reporter generated: /Users/lqi/Documents/lqi/work/test/appium/macacatest/NoSmoke/reports/index.html
  --> GET / 200
socket connected
(node:3352) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): FetchError: invalid json response body at http://localhost:3456/wd/hub/session reason: Unexpected token S in JSON at position 0
(node:3352) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  <-- GET /favicon.ico
  --> GET /favicon.ico 200
^[[1;9D^C%

crawler.config.yml配置

desiredCapabilities:
  platformName: 'android'
  deviceName: '192.168.59.101:5555'
  isWaitActivity: true
  # activity: 'LoginActivity'
  app: 'https://npmcdn.com/android-app-bootstrap@latest/android_app_bootstrap/build/outputs/apk/android_app_bootstrap-debug.apk'
# 2. Crawling option
crawlingConfig:
  platform: 'android'
  targetElements:
    loginAccount:
      actionType  : 2
      searchValue : 'please input username'
      actionValue : '中文+Test+12345678'
    loginPassword:
      actionType  : 2
      searchValue : 'please input password'
      actionValue : '111111'
    loginButton:
      actionType  : 1
      searchValue : 'Login'
    alertConfirm:
      actionType  : 1
      searchValue : 'yes'
SamuelZhaoY commented 6 years ago

确认下环境版本, 建议使用模拟器 android: 2.0.40 chrome: 1.0.6 ios: 2.0.27 puppeteer: 1.0.0

另外:192.168.59.101:5555 这个不是设备ID 请查看 adb devices

qileilove commented 6 years ago

@SamuelZhaoY 依然同样的问题 我看下 package.json 里面的依赖如下

"macaca-android": "^2.0.40",
    "macaca-chrome": "^1.0.6",
    "macaca-cli": "^2.0.10",
    "macaca-ios": "^2.0.27",
    "puppeteer": "^0.11.0",

确定版本不会有问题 "puppeteer"的版本 你写错了吧, npm官网上才是 0.11.0, 另外192.168.59.101:5555 这个是我用 genymotion启动的模拟器和android emulator一样 我看下log 主要是这两行错 client

(node:53667) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): FetchError: invalid json response body at http://localhost:3456/wd/hub/session reason: Unexpected token S in JSON at position 0
(node:53667) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

server

>> responseHandler.js:63:12 [master] pid:3333 Send Error Respone to Client: Error: Server responded with status code 404:
Cannot find module "/android_app_bootstrap/build/outputs" in package android-app-bootstrap@1.0.7
>> responseHandler.js:69:14 [master] pid:3333 Error: Server responded with status code 404:
Cannot find module "/android_app_bootstrap/build/outputs" in package android-app-bootstrap@1.0.7
    at Response.getBody (/usr/local/lib/node_modules/macaca-cli/node_modules/http-response-object/index.js:34:15)
    at downloadWithCache (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/common/helper.js:156:20)
    at Object._.configApp (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/common/helper.js:188:15)
    at Object.createDevice (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/server/controllers/session.js:26:18)
    at createDevice.next (<anonymous>)
    at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:65:19)
    at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
    at Promise (<anonymous>)
    at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
    at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)

我只是一个QA,懂一些开发 但是你们封装代码没人解释,我可能看不懂 抱歉 只能寻求你们帮助

SamuelZhaoY commented 6 years ago

@qileilove "puppeteer"的版本 你写错了吧, npm官网上才是 0.11.0" 关于版本的设定以及写法 请参考https://docs.npmjs.com/misc/semver

/android_app_bootstrap/build/outputs 这个属于驱动层的issue ,可以提在: https://github.com/alibaba/macaca/issues