【问题标题】:CodeCeptJs is it possible to parellel test with webdriver and appium?CodeCeptJs 是否可以使用 webdriver 和 appium 进行并行测试?
【发布时间】:2019-12-09 22:41:57
【问题描述】:

所以我正在尝试同时测试桌面和移动设备是否可以使用 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'
}```

【问题讨论】:

    标签: webdriver appium codeceptjs


    【解决方案1】:

    是的,但我是通过运行 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 文件中的帮助程序。

    要跨平台运行,请使用&amp; 运算符运行命令:npm run web &amp; npm run ios

    仅运行网络:npm run web

    仅运行 Android:npm run android

    运行网页 iOS:npm run ios

    希望能解决您的问题。祝你好运哦/

    【讨论】:

      【解决方案2】:

      不,您不能同时使用(部分)相同的 API 运行两个帮助程序。 一个帮手一个跑。

      您可以在 2 个不同的并行作业中并行运行它,例如在 CI 作业中。

      还有一个。你不应该在WebDriver 中设置Appium - 它们是两个不同的助手。助手在一个级别中定义

      helpers: {
       WebDriver: {
         ...
       },
       REST: {
         ...
       }
      },..
      

      但这不适用于一个配置(WebDriver/Appium/Puppeteer/others)中的类似帮助程序(具有类似 API)。 您应该使用 2 个配置:一个用于 Appium,一个用于 WebDriver。

      【讨论】:

        猜你喜欢
        • 2022-11-08
        • 2018-07-18
        • 2016-09-25
        • 2016-01-03
        • 2022-08-18
        • 2016-05-15
        • 2015-01-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多