我使用Appium和WebdriverIO为React本机应用程序创建了测试,它在android模拟器和真实设备上本地运行良好,但在AWS设备场上不起作用。本教程https://medium.com/jetclosing-engineering/react-native-device-testing-w-appium-node-and-aws-device-farm-295081129790我随后创建了一个测试。
问题是
[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不是一个函数
测试文件
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);
});
});
包裹json文件
{
"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文件
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文件安装和测试阶段
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教程,在AWS设备场上使用wd编写测试。
如果你需要更多信息,请告诉我。谢谢
问题已经解决,主要与Yml文件安装和测试阶段有关。我现在在安装阶段全局安装wdio cli和chai,然后在测试阶段使用npm安装并运行测试来安装所需的依赖项
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文件中的依赖项,所以我删除了包中的bundledDependencies。json文件,我正在yml安装阶段安装这些文件。
{
"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测试NG类型。我已经安装了appium模块并使其运行: 但是现在呢?如何编写和使用离子2测试? 这里说: 您的Android Appium Java TestNG测试必须包含在。他们指向Appium的官方网站,进一步解释如何在android或ios设备上使用Appiu
我试图将iOS XCTest设置为在AWS设备场上运行,但似乎无论我如何构建和上传它们,每次测试都会出错并失败。当我运行XCode时,它们会成功执行,但不会在AWS设备场上运行。 我甚至尝试了从非常简单的应用程序,没有任何api调用,但也失败了。 以下是AWS设备场界面中出现的错误。 你可以从这里看到日志
我使用的是react原生版本0.38,不知怎么的,打开开发者菜单的抖动手势已经停止工作。 设备已连接,我已经反转了8081端口。用于keyevent输入的adb外壳命令(adb外壳输入keyevent 82或KEYCODE_菜单)正在启动后台运行的应用程序。 该设备是一款带有5.1.1的小米红米3。 你知道我怎么打开开发者菜单吗?
在过去,android模拟器非常慢,我只使用设备来调试android应用程序。 React原生应用程序的首选开发环境、模拟器或设备是什么?
我已经使用Appium和Java以及TestNG为Android应用程序编写了一些测试。我的测试在模拟器上本地运行良好,但当我将它们上传到设备场时,我的测试总是失败。我已经尽可能地简化了我的测试,但它仍然不起作用。目前,我尝试运行的测试会在打开应用程序时出现的提示中找到并单击“允许权限”按钮。代码: 观看Device Farm提供的视频,我可以看到它打开并立即关闭我的应用程序。它甚至没有像应该的那
我正在尝试使用testng.xml...并且看起来设备场忽略了整个文件。 我的例子很简单。我有一个实例化测试类的工厂类,这就是我的xml文件的样子 我甚至尝试手动排除方法