本文介绍了在页面上找不到量角器错误Angular的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用量角器(2.1.0)为我的Angular(1.4)站点设置End-2-End测试。 Jasmine已安装且单元测试工作正常。当我运行量角器时,索引#/登录页面在浏览器窗口中加载,但没有代码运行,量角器报告此错误

I'm trying to set up End-2-End testing for my Angular (1.4) site using protractor (2.1.0). Jasmine is installed and unit tests are working fine. When I run protractor the index#/login page loads in a browser window but no code runs and protractor reports this error

我的量角器配置看起来像这样

My protractor config looks like this

exports.config = {
    allScriptsTimeout: 11000,
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    specs: [
        '*.js'
    ],
    rootElement:'html',
    capabilities: {
        'browserName': 'chrome'
    },
    baseUrl: 'http://localhost/SpectrumGMWeb/',
    framework: 'jasmine2',
    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    },
};

我的测试文件很简单

describe('my app', function() {

    describe('login', function() {

        beforeEach(function() {
            browser.get('index.html#/login');
        });

        it('should render login page when user navigates to login page', function() {
            expect(true).toBe(true);
        });

    });
});

ng-app =main在index.html的html元素上设置。该网站确实有效。

ng-app="main" is set on the html element of index.html. The website does work.

任何想法?

推荐答案

非常感谢大家的意见。我最后通过将所有index.html文件内容复制到新文件来解决此问题。似乎文件以某种方式损坏了量角器不喜欢的方式。我知道这听起来很简单,但我浪费了整整2天的时间,所以希望它可以帮助别人。

Well thanks everyone for your input. I did finally fix this problem by copying all the index.html file contents to a new file. It seems that somehow the file was corrupted in a way that protractor did not like. I know it sounds simple but I wasted 2 full days on this so hope it helps someone.

这篇关于在页面上找不到量角器错误Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 21:30