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

使用量角器和角度4运行E2E测试

  •  2
  • joesan  · 技术社区  · 7 年前

    我遇到了一些我无法解决的错误!

    以下是错误消息:

    /usr/local/bin/node /Users/jothi/Books/Angular/ng-book-_The_Complete_Guide_to_Angular_4_-_basic_package/ng-book-code/http/node_modules/protractor/bin/protractor /Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/helpers/protractor-intellij/lib/protractor-intellij-config.js --intellijOriginalConfigFile=/Users/jothi/Books/Angular/ng-book-_The_Complete_Guide_to_Angular_4_-_basic_package/ng-book-code/http/protractor.conf.js --disableChecks
    (node:63426) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
    [19:38:44] I/launcher - Running 1 instances of WebDriver
    [19:38:44] I/direct - Using ChromeDriver directly...
    [19:38:44] E/direct - Error code: 135
    [19:38:44] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    [19:38:44] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    

    有谁能告诉我问题到底是什么以及如何解决?

    编辑:这是我的量角器。配置文件:

    // Protractor configuration file, see link for more information
    // https://github.com/angular/protractor/blob/master/lib/config.ts
    
    const { SpecReporter } = require('jasmine-spec-reporter');
    
    exports.config = {
      allScriptsTimeout: 11000,
      specs: [
        './e2e/**/*.e2e-spec.ts'
      ],
      capabilities: {
        'browserName': 'chrome'
      },
      directConnect: true,
      baseUrl: 'http://localhost:4200/',
      framework: 'jasmine',
      jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
      },
      beforeLaunch: function() {
        require('ts-node').register({
          project: 'e2e/tsconfig.e2e.json'
        });
      },
      onPrepare() {
        jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
      }
    };
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   Xotabu4    7 年前

    在运行测试之前,尝试使用webdriver manager下载chromedriver:

    "scripts": {
        "pretest": "webdriver-manager update",
        "test": "protractor protractor.conf.js",
    },
    

    npm test

    这将安装ChromeDriver并运行测试

        2
  •  0
  •   Tarun Lalwani    7 年前

    directConnect: true, 在量角器中。js直接运行测试用例,而不是使用webdriver!

     ....
     capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        'args': ['--no-sandbox', '--test-type=browser'],
        'prefs': {
          'download': {
            'prompt_for_download': false,
            'default_directory': 'C:/Temp'
          }
        }
    }
      },
      directConnect: true,
      baseUrl: conf.baseUrl,
      framework: 'jasmine',
      jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
      },
      ...