Protractor Angular 2 失败:未知错误:未定义角度

Protractor Angular 2 Failed: unknown error: angular is not defined(Protractor Angular 2 失败:未知错误:未定义角度)
本文介绍了Protractor Angular 2 失败:未知错误:未定义角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我收到以下错误:

  • 失败:未知错误:未定义角度

这仅在使用诸如by.model"之类的特定角度选择器时发生.但是诸如by.css"之类的选择器可以正常工作.这是一个 Angular 2 应用程序...

测试

it('应该设置焦点', () => {//这行得通//var input = element(by.css('myclass'));//这失败了var input = element(by.model('config.value'));输入.清除();input.sendKeys('test');input.sendKeys(Key.TAB);输入.点击();var highlightText = browser.executeScript(function getSelectionText(){返回 window.getSelection().toString();});期望(highlightedText).toEqual('test');});出口.config = {baseUrl: 'http://localhost:5555',眼镜: ['dist/dev/**/*.e2e.js'],排除: [],框架:'jasmine2',allScriptsTimeout: 110000,茉莉花节点选择:{显示时间:真,显示颜色:真,isVerbose:假,包括堆栈跟踪:假,默认超时间隔:400000},直接连接:真,能力:{浏览器名称":铬"},onPrepare:函数(){var SpecReporter = require('jasmine-spec-reporter');jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));browser.ignoreSynchronization = false;},使用AllAngular2AppRoots:真};

铬=49.0.2623.87铬驱动程序=2.9.248315平台=Windows NT 6.1 SP1 x86_64节点=5.9.1

解决方案

我在 angular.io 网站的开发者文档下找到了答案.

目前不支持角度选择器 by.model 和 by.binding.目前尚不清楚这些是可能的功能还是它们正在为 angular 2 工作.

I'm getting the following error:

  • Failed: unknown error: angular is not defined

This only happens when using angular specific selectors like "by.model". But selectors such as "by.css" work correctly . This is an Angular 2 app...

Test

it('should set focus', () => {
    //This works
    //var input = element(by.css('myclass'));
    //This fails
    var input = element(by.model('config.value'));
    input.clear();
    input.sendKeys('test');
    input.sendKeys(Key.TAB);
    input.click();
    var highlightedText = browser.executeScript(function getSelectionText()       
    {         
         return window.getSelection().toString(); 
    });
    expect(highlightedText).toEqual('test');
 });


exports.config = {
  baseUrl: 'http://localhost:5555',

  specs: [
    'dist/dev/**/*.e2e.js'
  ],
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 400000
  },
  directConnect: true,

  capabilities: {
    'browserName': 'chrome'
  },

  onPrepare: function() {
    var SpecReporter = require('jasmine-spec-reporter');
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));

    browser.ignoreSynchronization = false;
  },

  useAllAngular2AppRoots: true
};

chrome=49.0.2623.87 chromedriver=2.9.248315 platform=Windows NT 6.1 SP1 x86_64 node=5.9.1

解决方案

I found the answer on the angular.io site under developer docs.

Upgrading from 1.x

Right now angular selectors by.model and by.binding are not supported. Its not clear if these are features that are possible or that they are working on for angular 2.

这篇关于Protractor Angular 2 失败:未知错误:未定义角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

jasmine.createSpyObj with properties(jasmine.createSpyObj 与属性)
What#39;s a good way to reuse test code using Jasmine?(使用 Jasmine 重用测试代码的好方法是什么?)
Does Jasmine#39;s toThrow matcher require the argument to be wrapped in an anonymous function?(Jasmine 的 toThrow 匹配器是否需要将参数包装在匿名函数中?)
Jasmine - Spying on a method call within a constructor(Jasmine - 在构造函数中监视方法调用)
Getting requirejs to work with Jasmine(让 requirejs 与 Jasmine 一起工作)
How can I spy on a getter property using jasmine?(如何使用 jasmine 监视 getter 属性?)