Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor error Angular could not be found on the page

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

Failed: Angular could not be found on the page http://localhost/SpectrumGMWeb/index.html#/login : retries looking for angular exceeded

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
    },
};

My test file is very simple

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" is set on the html element of index.html. The website does work.

Any ideas?

like image 472
nuander Avatar asked Jul 31 '15 17:07

nuander


People also ask

How do I select a drop down list from a protractor?

var SelectWrapper = require('select-wrapper'); var mySelect = new SelectWrapper(by.id('locregion')); # select an option by value mySelect. selectByValue('4'); # select by visible text mySelect.


3 Answers

Try putting a browser.ignoreSynchronization = true; before you do a browser.get() in your login function.

like image 102
Rahul Vig Avatar answered Oct 23 '22 06:10

Rahul Vig


If you need to navigate to a page which does not use Angular then Add this line of code before browser.get() line there:

browser.waitForAngularEnabled(false);

Reference : https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load

like image 8
Mukesh Rajput Avatar answered Oct 23 '22 05:10

Mukesh Rajput


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.

like image 6
nuander Avatar answered Oct 23 '22 06:10

nuander