首页 > 解决方案 > 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'
}```

标签: webdriverappiumcodeceptjs

解决方案


是的,但我是通过使用 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/


推荐阅读