代码之家  ›  专栏  ›  技术社区  ›  Devleena

在并行执行时,如何对所有浏览器只执行一次查询

  •  0
  • Devleena  · 技术社区  · 6 年前

    我使用的是量角器5.2.2和cucumber 3.2.0。我通过指定多个功能来执行并行执行,如下所示。

    multiCapabilities: [
    {
    browserName: 'chrome',
    },
    {
    browserName: 'chrome',
    }],
    

    我只需要对所有浏览器执行一次查询。但是现在该查询正在对每个浏览器执行。当脚本由命令'grandor conf.js'运行时,如何将该查询设置为只执行一次。

    1 回复  |  直到 6 年前
        1
  •  0
  •   yong    6 年前

    你可以试试这个 beforeLaunch() 量角器配置js。

      /**
       * A callback function called once configs are read but before any
       * environment setup. This will only run once, and before onPrepare.
       *
       * You can specify a file containing code to run by setting beforeLaunch to
       * the filename string.
       *
       * At this point, global variable 'protractor' object will NOT be set up,
       * and globals from the test framework will NOT be available. The main
       * purpose of this function should be to bring up test dependencies.
       */
      beforeLaunch?: () => void;
    

      exports.config = {
    
          multiCapabilities: [],          
    
          specs:[],
    
          beforeLaunch: function(){
               // execute query at here
          }
          ...
      };