zoukankan      html  css  js  c++  java
  • [Protractor] Running tests on multiple browsers

    Testing your AngularJS application on multiple browsers is important, and Protractor offers this ability through the multiCapabilities configuration option. Learn how to use this option, as well as configure your e2e tests to run on only a single browser for rapid development.

    By default, protractor will use chrome as default browser. You can also use other browser:

    exports.config = {
    
        capabilities: {
            name: "Firefox",
            browserName: "firefox"
        },
        specs: [
            './e2etest/**/*.spec.js'
        ],
        seleniumAddress: 'http://localhost:4444/wd/hub'
    };

    If you want to run on multi browsers, then you can use 'multiCapabilities':

    exports.config = {
        multiCapabilities: [
            {
                name: "Chrome",
                browserName: "chrome"
            },
            {
                name: "Firefox",
                browserName: "firefox"
            }
        ],
        specs: [
            './e2etest/**/*.spec.js'
        ],
        seleniumAddress: 'http://localhost:4444/wd/hub'
    };

    But it probably good when you are actually developing the project, you can run only on one browser for saving time, so you can modify the scripts tags:

        "test-e2e": "protractor conf.js",
        "test-e2e-dev": "protractor conf.js --chrome"

    More flexable code:

    var browsers = {
      firefox: {
        name: 'Firefox',
        browserName: 'firefox'
      },
      chrome: {
        name: 'Chrome',
        browserName: 'chrome'
      }
    }
    
    var config = {
      specs: [
        './e2etest/**/*.spec.js'
      ],
    
      baseUrl: 'http://localhost:3333'
    };
    
    if (process.argv[3] === '--chrome') {
      config.capabilities = browsers.chrome;
    }  else {
      config.multiCapabilities = [
        browsers.firefox,
        browsers.chrome
      ]
    }
    
    exports.config = config;

    package.json:

      "scripts": {
        "test-start": "webdriver-manager start",
        "test-e2e": "protractor conf.js",
        "test-e2e-dev": "protractor conf.js --chrome"
      },
  • 相关阅读:
    C# 控制反转
    控制反转和依赖注入
    C#中使用AOP
    jquery ajax
    python(7)- 小程序练习:循环语句for,while实现99乘法表
    007所谓性格与条件并不是成功的阻碍,懦弱才是
    006学习有可能速成吗
    005自学与有人带着哄着逼着学的不同在于自学是一种成熟的自律
    005单打独斗意味着需要更好地管理自己
    004真正的教育是自我教育,真正的学习是自学
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5201949.html
Copyright © 2011-2022 走看看