angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Problem updating angular from 1.2 to 1.3 #1576

Closed stefanosusini closed 9 years ago

stefanosusini commented 9 years ago

I've just updated angular to 1.3.4 version and my protractor test (that's just a fake because I'm just starting a new project) is no more running properly. In particular the function browser.waitForAngular doesn't work any more. This is my configuration:

// protractor-conf.js
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['src/**/*-e2e.js'],
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: ['--disable-extensions']
        }
    },
};
// main-e2e.js
describe('test page', function() {
    it('check an input box', function() {
        browser.get('http://localhost:8080');

        browser.waitForAngular().then(function(){
            var input = element(by.model('test'));        
            input.click();
            expect(input.getAttribute('value')).toBe('true');
        });
    });
});

My app is obviously running on http://localhost:8080. I'm using GRUNT to run it:

grunt.registerTask('e2e',
   ['http-server', 'protractor_webdriver', 'protractor:all']);

The following is the output;

$ grunt e2e
Running "clean:build" (clean) task
>> 1 path cleaned.

Running "copy:build" (copy) task
Created 40 directories, copied 287 files

Running "sass:build" (sass) task

Running "env:test" (env) task

Running "config" task

Running "http-server:dev" (http-server) task
Server running on  localhost:8081
Hit CTRL-C to stop the server

Running "protractor_webdriver:all" (protractor_webdriver) task
Starting Selenium server
Started Selenium server: http://127.0.0.1:4444

Running "protractor:all" (protractor) task
Using the selenium server at http://localhost:4444/wd/hub
Session created: count=1, browserName=chrome, chromeOptions={args=[--disable-extensions]}
F

Failures:

  1) test page check an input box
   Message:
     Error: Error while waiting for Protractor to sync with the page: {}
   Stacktrace:
     Error: Error while waiting for Protractor to sync with the page: {}
    at Error (<anonymous>)
==== async task ====
Protractor.waitForAngular()
    at [object Object].<anonymous> (/home/susini/dev/gunsonpegs/GOP2-FE/src/app/test/main-e2e.js:7:17)
==== async task ====
Asynchronous test function: it()
Error
    at [object Object].<anonymous> (/home/susini/dev/gunsonpegs/GOP2-FE/src/app/test/main-e2e.js:4:5)
    at Object.<anonymous> (/home/susini/dev/gunsonpegs/GOP2-FE/src/app/test/main-e2e.js:3:1)

Finished in 2.292 seconds
1 test, 1 assertion, 1 failure

Session deleted: Going to shut down the Selenium server
Shutting down Selenium server: http://127.0.0.1:4444
Shut down Selenium server: http://127.0.0.1:4444 (OKOK)
>> 
Fatal error: protractor exited with code: 1

As I said, If I use Angular 1.2.27 the test run correctly, as I update to 1.3.4, it stops.

The app is a bare scaffold, but it's manually bootstrapped.

Thanks

juliemr commented 9 years ago

I imagine this has something to do with your manual bootstrapping, but without knowing how that works I can't help you further. Try replacing browser.get with browser.driver.get.

stefanosusini commented 9 years ago

I've tried the modification, but sadly it doesn't work for me. Unfortunately I cannot bootstrap the application with ng-app because I'm using require.JS to load my scripts. I've tried also to load angularjs.org homepage to try if it worked and it did.

ghguy commented 9 years ago

If this going to be fixed soon? We are using requirejs too with AngularJS and we are thinking to migrate to 1.3 (soon)! :(

juliemr commented 9 years ago

@stefanosusini how does it not work?

If you are doing custom bootstrap, you will probably need some custom browser.wait function to know when your page is loaded.

juliemr commented 9 years ago

This seems like an issue with a couple specific apps and haven't heard any updates, so closing. Please open a new issue if there is a problem we can help with!

andrewboni commented 9 years ago

Also running into a similar issue around manually bootstrapping (I'm using RequireJS with Angular):

    Running "protractor:signup" (protractor) task
    Using ChromeDriver directly...
    [launcher] Running 1 instances of WebDriver
    F.
    /home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
      var template = new Error(this.message);
                     ^
    UnknownError: unknown error: [ng:btstrpd] http://errors.angularjs.org/1.2.28/ng/btstrpd?p0=document
      (Session info: chrome=41.0.2272.118)
      (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.14.28-031428-generic x86_64)
        at new bot.Error (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
        at Object.bot.response.checkResponse (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
        at /home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:377:20
        at [object Object].promise.ControlFlow.runInFrame_ (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
        at [object Object].promise.Callback_.goog.defineClass.notify (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
        at [object Object].promise.Promise.notify_ (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
        at Array.forEach (native)
        at Object.goog.array.forEach (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43)
        at [object Object].promise.Promise.notifyAll_ (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)
        at [object Object].goog.async.run.processWorkQueue [as _onTimeout] (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
        at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
    From: Task: WebDriver.manage().timeouts().setScriptTimeout(11000)
        at [object Object].webdriver.WebDriver.schedule (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:360:15)
        at [object Object].webdriver.WebDriver.Timeouts.setScriptTimeout (/home/ubuntu/Iterable/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:1367:23)
        at [object Object].Runner.createBrowser (/home/ubuntu/Iterable/node_modules/protractor/lib/runner.js:181:30)
        at /home/ubuntu/Iterable/node_modules/protractor/lib/runner.js:257:21
        at _fulfilled (/home/ubuntu/Iterable/node_modules/protractor/node_modules/q/q.js:797:54)
        at self.promiseDispatch.done (/home/ubuntu/Iterable/node_modules/protractor/node_modules/q/q.js:826:30)
        at Promise.promise.promiseDispatch (/home/ubuntu/Iterable/node_modules/protractor/node_modules/q/q.js:759:13)
        at /home/ubuntu/Iterable/node_modules/protractor/node_modules/q/q.js:573:44
        at flush (/home/ubuntu/Iterable/node_modules/protractor/node_modules/q/q.js:108:17)
        at process._tickCallback (node.js:419:13)
        at Function.Module.runMain (module.js:499:11)
        at startup (node.js:119:16)
        at node.js:906:3
    [launcher] Process exited with error code 1

Was a good solution ever found?

I've added rootElement: 'div' with no luck as well...

Thanks!