webdriver - CodeCeptJs 是否可以使用 webdriver 和 appium 进行并行测试?
问题描述
所以我试图同时测试桌面和移动设备是否可以使用 codeceptjs 或者我需要一个接一个地运行?
这是我的 codecept 配置文件:-
tests: './*_test.js',
output: './output',
multiple: {
parallel:{
// Splits tests into 2 chunks
chunks:2,
//Run all tests in chrome and firefox can add internet explorer 11 very slow though
browsers: ['chrome', 'firefox'] //'internet explorer']
}
},
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'chrome',
Appium: {
app: '/path/to/app/foo.app',
platform: 'iOS',
desiredCapabilities: {
deviceName: "iPhone 6",
bundelId: "com.app.foo",
automationName: "XCUITest",
autoWebview: false,
newCommandTimeout: 3600,
platformVersion: "11.2",
fullReset: false,
noReset: true,
locationServicesEnabled: true
locationServicesAuthorized: true,
calendarAccessAuthorized: true
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'CodeCeptJs'
}```
解决方案
是的,但我是通过使用 npm 来学习的。
您必须为文件中的每个平台创建脚本package.json
以覆盖codecept.conf.js.
注释掉文件中的帮助程序中的帮助codecept.conf.js
程序。
将以下代码添加到您的package.json
文件中。
"scripts": {
"web": "codeceptjs run -c codecept.conf.js --override '{\"helpers\": {\"WebDriver\": {\"url\": \"<your_url>\", \"browser\": \"chrome\", \"host \": \"127.0.0.1\", \"port\": 4444, \"restart\": \"false\", \"windowSize\": \"1920x1680\", \"desiredCapabilities\": {\"chromeOptions\": {\"args\": [\"-disable-gpu\", \"-window-size=1200,1000\", \"-no-sandbox\"]}}}}}'--steps",
"ios": "codeceptjs run -c codecept.conf.js --override '{\"helpers\": {\"Appium\": {\"app\": \"/path/to/app/foo.app\", \"platform\": \"iOS\", \"desiredCapabilities\": {\"deviceName\": \"iPhone 6\", \"bundelId\": \"com.app.foo\", \"automationName\": \"XCUITest\", \"autoWebview\": false, \"newCommandTimeout\": 3600, \"platformVersion\": \"11.2\", \"fullReset\": false, \"noReset\": true, \"locationServicesEnabled\": true, \"locationServicesAuthorized\": true, \"calendarAccessAuthorized\": true}}}}'--steps",
"android": "codeceptjs run -c codecept.conf.js --override '{\"helpers\": {\"Appium\": {\"app\": \"<path_apk>/<name_apk>.apk\", \"platform\": \" Android\", \"device\": \"<code_your_device>\", \"desiredCapabilities\": {\"platformVersion\": \"<version_your_android>\", \"platformName\": \"Android\", \"deviceName\": \"Anyname\", \"appPackage\": \"your_appPackage>\", \"appActivity\": \"<your_appActivity>\"}}}}'--steps"
}
请务必注释掉codecept.conf.js
文件中的助手。
要跨平台运行,请使用&
运算符运行命令:npm run web & npm run ios
仅运行网络:npm run web
只运行安卓:npm run android
运行网页 iOS:npm run ios
我希望这能解决你的问题。祝你好运o/
推荐阅读
- php - Changing the font colour of data from database
- python - 在 Android 手机上流式传输实时视频
- ssl - 仅使用 HAProxy 为端口 443 上的某些流量提供证书
- spring - 将活动配置文件设置为“本机”,在 Spring Boot 2 配置服务器中是必需的
- r - 闪亮的应用程序不适用于 Google Chrome/Chromium
- php - 如何在不复制的情况下使用 php 创建唯一的 6 到 8 位代码
- sharepoint - 如何在 SharePoint Designer 中获取人员列的总数
- spring-batch - 如何永久禁用 Spring Job
- javascript - Node.js:接收链式数据,同时异步保存到数据库
- c# - ASP.NET 核心操作不加载。可能路由不好?