AWS 设备场反应原生 appium nodejs webdriverio 测试不起作用 [英] AWS device farm react native appium nodejs webdriverio test's not working

查看:91
本文介绍了AWS 设备场反应原生 appium nodejs webdriverio 测试不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Appium 和 WebdriverIO 为 React Native 应用程序创建了测试,它在 android 模拟器和真实设备上本地运行良好,但在 AWS 设备场上不起作用.本教程 https://medium.com/jet封闭-engineering/react-native-device-testing-w-appium-node-and-aws-device-farm-295081129790我跟着创建了一个测试.

I have created test for React Native application using Appium and WebdriverIO, it's working fine locally on an android emulator and on a real device, but its not working on AWS device farm. This tutorial https://medium.com/jetclosing-engineering/react-native-device-testing-w-appium-node-and-aws-device-farm-295081129790 I followed to create a test.

问题是

[0-0] 2020-05-06T14:01:27.360Z INFO webdriver: COMMAND findElement("accessibility id", "app-root")
[0-0] 2020-05-06T14:01:27.370Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/5a7350a3-e8c2-4c9e-b31a-347ea4defcdb/element
[0-0] 2020-05-06T14:01:27.370Z INFO webdriver: DATA { using: 'accessibility id', value: 'app-root' }
[0-0] 2020-05-06T14:01:27.378Z INFO webdriver: COMMAND findElement("accessibility id", "loginEmail")
[0-0] 2020-05-06T14:01:27.388Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/5a7350a3-e8c2-4c9e-b31a-347ea4defcdb/element
2020-05-06T14:01:27.388Z INFO webdriver: DATA { using: 'accessibility id', value: 'loginEmail' }
2020-05-06T14:01:27.390Z INFO webdriver: COMMAND findElement("accessibility id", "app-root")
2020-05-06T14:01:27.393Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/5a7350a3-e8c2-4c9e-b31a-347ea4defcdb/element
2020-05-06T14:01:27.393Z INFO webdriver: DATA { using: 'accessibility id', value: 'app-root' }
[0-0] TypeError in "Simple App testing Valid Login Test"
$(...).setValue is not a function
[0-0] 2020-05-06T14:01:27.426Z INFO webdriver: COMMAND deleteSession()
[0-0] 2020-05-06T14:01:27.426Z INFO webdriver: [DELETE] http://127.0.0.1:4723/wd/hub/session/5a7350a3-e8c2-4c9e-b31a-347ea4defcdb
[0-0] 2020-05-06T14:01:28.306Z WARN webdriver: Request failed with status 500 due to An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up

同样的问题是 waitForDisplayed $(...).waitForDisplayed 不是函数

The same issue is for waitForDisplayed $(...).waitForDisplayed is not a function

测试文件

var expect = require('chai').expect;

describe('Simple App testing', () => {

  it('App is loaded', async function () {
    expect($("~app-root")).to.exist;    
});

  it('Valid Login Test', async => {
    $("~app-root");
    $('~loginEmail').setValue("customer11@yopmail.com");
    $('~loginPassword').setValue("123456");

    $("~login").click();
    //$("~app-root").waitForDisplayed(11000, false);

    expect(true).to.equal(true);
  });
});

Package.json 文件

Package.json file

{
  "name": "tests",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "npm install && npx wdio ./wdio.conf.local.js",
    "package": "npm install && npm-pack-zip"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@wdio/cli": "^6.1.2",
    "@wdio/local-runner": "^6.1.2",
    "@wdio/mocha-framework": "^6.1.0",
    "@wdio/spec-reporter": "^6.0.16",
    "@wdio/sync": "^6.1.0",
    "wdio-chromedriver-service": "^6.0.2",
    "chromedriver": "^81.0.0",
    "chai": "^4.2.0",
    "webdriverio": "^6.1.2"
  },
  "devDependencies": {
    "npm-bundle": "^3.0.3",
    "npm-pack-zip": "^1.2.7"
  },
  "bundledDependencies": [
    "@wdio/cli",
    "@wdio/mocha-framework",
    "@wdio/local-runner",
    "@wdio/spec-reporter",
    "@wdio/sync",
    "webdriverio",
    "chai",
    "chromedriver",
    "wdio-chromedriver-service"
  ]
}

wdio.config.js 文件

wdio.config.js file

exports.config = {

    runner: 'local',

    specs: [
        './test/specs/**/*.js'
    ],
    exclude: [
        // 'path/to/excluded/files'
    ]
    maxInstances: 1,
    capabilities: [{    
        maxInstances: 1,
        appWaitDuration: 100000,
        appWaitActivity: '*'
    }],
    logLevel: 'info',
    bail: 0,
    baseUrl: 'http://localhost',
    path: '/wd/hub',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services: ['appium'],
    port: 4723,
    framework: 'mocha',

    reporters: ['spec'],

    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },
}

Yml 文件安装和测试阶段

Yml file install and test phases

phases:
  install:
    commands:
      - npm install -g appium
      - export APPIUM_VERSION=1.17.0
      - avm $APPIUM_VERSION
      - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium  /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js

      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - echo $DEVICEFARM_TEST_PACKAGE_PATH
      - npm install

  test:
    commands:
      - echo "Navigate to test source code"
      - cd $DEVICEFARM_TEST_PACKAGE_PATH/node_modules/*
      - echo "Start Appium Node test for Qbunk Android"
      - ls
      - echo $DEVICEFARM_TEST_PACKAGE_PATH
      - npm install
      - echo "Installing wdio"
      - npm install --save webdriverio @wdio/cli
      - echo "Installing chai"
      - npm install --save chai
      - npx wdio $DEVICEFARM_TEST_PACKAGE_PATH/wdio.conf.js --spec $DEVICEFARM_TEST_PACKAGE_PATH/test/specs/*.js          

有趣的是,这个 https://aws.amazon.com/blogs/mobile/testing-mobile-apps-across-hundreds-of-real-devices-with-appium-node-js-and-aws-device-farm/ 我遵循的 AWS 教程并使用 wd 编写了我的测试,在 AWS 设备场上运行良好.

Interesting thing is that this https://aws.amazon.com/blogs/mobile/testing-mobile-apps-across-hundreds-of-real-devices-with-appium-node-js-and-aws-device-farm/ AWS tutorial I followed and write my test with wd working fine on AWS Device farm.

如果您需要更多信息,请告诉我.谢谢

Kindly let me know if you need more information. Thanks

推荐答案

问题已解决,主要与Yml文件安装和测试阶段有关.我现在在安装阶段全局安装 wdio cli 和 chai 之后我使用 npm install 安装所需的依赖项并在测试阶段运行测试

The issue has been resolved, it's mainly related to the Yml file install and test phases. I am now installing wdio cli and chai globally in the install phase after that I am installing required dependencies using npm install and running test's in test phase

phases:
  install:
    commands:
      - export APPIUM_VERSION=1.16.0
      - avm $APPIUM_VERSION
      - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium  /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js
      - ls
      - echo "Installing wdio globally"
      - npm install -g webdriverio @wdio/cli
      - echo "Installing chai globally"
      - npm install -g chai
      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - npm install

  test:
    commands:
      - echo "Navigate to test source code"
      - cd $DEVICEFARM_TEST_PACKAGE_PATH/node_modules/*
      - npx wdio $DEVICEFARM_TEST_PACKAGE_PATH/wdio.conf.js --spec $DEVICEFARM_TEST_PACKAGE_PATH/test/specs/*.js    

另外,我不需要 zip 文件中的依赖项,所以我删除了 package.json 文件中的 bundledDependencies,我在 yml 安装阶段安装这些.

Also, I don't need dependencies in a zip file, so I removed bundledDependencies in package.json file, I am installing these in yml install phase.

{
  "name": "tests",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "npm install && npx wdio ./wdio.conf.local.js",
    "package": "npm install && npm-pack-zip"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@wdio/cli": "^6.1.9",
    "@wdio/local-runner": "^6.1.2",
    "@wdio/mocha-framework": "^6.1.0",
    "@wdio/spec-reporter": "^6.0.16",
    "@wdio/sync": "^6.1.0",
    "chai": "^4.2.0",
    "chromedriver": "^81.0.0",
    "wdio-chromedriver-service": "^6.0.2",
    "webdriverio": "^6.1.9"
  },
  "devDependencies": {
    "npm-bundle": "^3.0.3",
    "npm-pack-zip": "^1.2.7"
  }
}

这篇关于AWS 设备场反应原生 appium nodejs webdriverio 测试不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆