2016-03-15 26 views

回答

-3

可能有更好的方法來做到這一點,但目前我只是執行這些作爲併發的Grunt任務。

1)添加咕嚕併發插件

npm install grunt-concurrent --save-dev 

2)添加一個任務grunt.initConfig下的每個瀏覽器。我們可以將瀏覽器添加爲arg來重新使用我們的配置文件。

protractor: { 
     options: { 
      keepAlive: true, 
      singleRun: false, 
      configFile: "test/protractor.conf.js" 
     }, 
     run_chrome: { 
      options: { 
       args: { 
        browser: "chrome" 
       } 
      } 
     }, 
     run_firefox: { 
      options: { 
       args: { 
        browser: "firefox" 
       } 
      } 
     } 
    }, 

3)將這些註冊爲任務;

grunt.registerTask('protractor-chrome', ['protractor:run_chrome']); 
grunt.registerTask('protractor-firefox', ['protractor:run_firefox']); 

4)grunt.initConfig

concurrent: { 
     protractor_test: ['protractor-chrome', 'protractor-firefox'] 
    }, 

5下創建並行任務)添加併發

grunt.registerTask('protractor-e2e', ['concurrent:protractor_test']); 

繁重的任務和執行,應該給你併發量角器測試。

希望這會有所幫助。 :)

+0

我想這將在同一系統中執行腳本,2個瀏覽器說Chrome和Firefox。對?? –

+0

是啊!那就對了。這是你尋求的答案嗎? :) –

+0

不,我想執行它在2個不同的系統 –

2

終於得到了答案:-)

第1步:使用下面的命令 的Java啓動硒獨立的罐子硒的服務器獨立-2.42.2.jar -port 5041

這裏5041是一個端口號。

步驟2:添加的代碼下面的行中配置文件

multiCapabilities: { browserName: '狩獵', shardTestFiles:真, seleniumAddress: 'http://IP1:5041/wd/hub', 規格:」 .. /xyz.js', MAXINSTANCES:1 },{ browserName: '狩獵', shardTestFiles:真, seleniumAddress: 'http://IP2:5041/wd/hub',
種規格:」 ../pqr.js', MAXINSTANCES:1 } ],

注意:您需要同時在系統啓動硒獨立。

相關問題