Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

javascript - E2E testing on multiple/parallel browsers in Protractor?

Using Protractor how do I setup/add a parallel browsers for testing.

example: Test suites on not only chrome, but also firefox? Also is there a simple way of test for mobile? say ios8 safari or mobile chrome?

Question:

How do I write the exports.config object to support chrome and firefox in parallel suite testing?

   exports.config = {
      multiCapabilities: [
        {
          'browserName': 'chrome',
          'chromeOptions': {
            args: ['--test-type']
          }
        }
      ]}
    suites: {
        homePageFooter: 'protractor/homePage/footer.spec.js'
      },
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using Protractor how do I setup/add a parallel browsers for testing.

You need to list your browsers in multiCapabilities:

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

Also is there a simple way of test for mobile? say ios8 safari or mobile chrome?

One option would be to use Appium framework, here are the relevant documentation sections:

Another option would be to use Browserstack (or Sauce Labs) as your selenium server. There is a huge variety of browsers/platforms to choose from, including different mobile devices.

Here is a sample config from one of our internal projects:

'use strict';

var browserstackUser = 'user';
var browserstackKey = 'key';

exports.config = {
    multiCapabilities: [
        {
            'browserstack.user': browserstackUser,
            'browserstack.key': browserstackKey,
            'browserstack.local': 'true',
            'browserstack.debug': 'true',

            'browserName': 'Chrome',
            'os': 'Windows',
            'os_version': '8',

            specs: [
                '*.spec.js'
            ],
            exclude: [
                'footer.disabledCookies.spec.js',
                'footer.disabledFlash.spec.js'
            ]
        },

        {
            'browserstack.user': browserstackUser,
            'browserstack.key': browserstackKey,
            'browserstack.local': 'true',
            'browserstack.debug': 'true',

            'browserName': 'Internet Explorer',
            'browser_version': '9.0',
            'os': 'Windows',
            'os_version': '7',
            'resolution': '1024x768',

            specs: [
                '*.spec.js'
            ],
            exclude: [
                'footer.disabledCookies.spec.js',
                'footer.disabledFlash.spec.js'
            ]
        }
    ],

    maxSessions: 2,

    // Browserstack's selenium server address
    seleniumAddress: 'http://hub.browserstack.com/wd/hub',

    framework: 'jasmine',

    allScriptsTimeout: 300000,

    baseUrl: 'http://localhost:9001',

    onPrepare: function () {
        require('jasmine-reporters');
        var capsPromise = browser.getCapabilities();
        capsPromise.then(function (caps) {
            var browserName = caps.caps_.browserName.toUpperCase();
            var browserVersion = caps.caps_.version;
            var prePendStr = browserName + "-" + browserVersion + "-";
            jasmine.getEnv().addReporter(new
                jasmine.JUnitXmlReporter("test-results", true, true, prePendStr));
        });
    },

    jasmineNodeOpts: {
        showColors: true,
        isVerbose: true,
        includeStackTrace: true,
        defaultTimeoutInterval: 3600000
    }
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...