angular / protractor

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

syncronization fails. Angular 1.2.9 #447

Closed DanielaValero closed 10 years ago

DanielaValero commented 10 years ago

Coming from issue #325

Issue description:

When ignoring synchronisation the tests correctly, but then need to handle async calls manually. When synchronisation is not ignored tests are executed but produce a timeout error

this is an example:

describe('login', function () {
    beforeEach(function () {
        browser.get('/app/login');
//        browser.ignoreSynchronization = true; (If this is present, it goes ok)
    });

    it('should render login when user navigates to /app/login', function () {
        var name = element(by.tagName('form')).getAttribute('name');
        expect(name).toBe('loginForm');
    });
});

Config file:

exports.config = {
    seleniumServerJar: null,
    seleniumPort: null,

    chromeDriver: '../node_modules/protractor/selenium/chromedriver',

    chromeOnly: false,
    seleniumArgs: [],
    sauceUser: null,
    sauceKey: null,
    seleniumAddress: 'http://localhost:4444/wd/hub',
    allScriptsTimeout: 11000,
    specs: [
        '../test/e2e/*.js'
    ],

    // https://code.google.com/p/selenium/wiki/DesiredCapabilities
    // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
    capabilities: {
        'browserName': 'chrome'
    },

    // A base URL for your application under test. Calls to protractor.get()
    // with relative paths will be prepended with this.
    baseUrl: 'http://localhost:8080/app',

    rootElement: 'html',

    onPrepare: function () {
        //     jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
        //         'outputdir/', true, true));
    },

    params: {
        login: {
            user: 'jane',
            password: '1234'
        }
    },

    framework: 'jasmine',

    // See the full list at https://github.com/juliemr/minijasminenode
    jasmineNodeOpts: {
        // onComplete will be called just before the driver quits.
        onComplete: null,
        // If true, display spec names.
        isVerbose: true,
        // If true, print colors to the terminal.
        showColors: true,
        // If true, include stack traces in failures.
        includeStackTrace: true,
        // Default time to wait in ms before a test fails.
        defaultTimeoutInterval: 30000
    }
};

and partial

<form class="login-form" novalidate name="loginForm" ng-submit="login()">
<span>some content</span>
</html>

Update:

And the stacktrace:

Stacktrace:
     Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
    at Error (<anonymous>)
==== async task ====
WebDriver.executeScript()
    at Protractor.waitForAngular (/Users/danielavalero/workspace/dashboard/node_modules/protractor/lib/protractor.js:278:22)
    at Protractor.findElement (/Users/danielavalero/workspace/dashboard/node_modules/protractor/lib/protractor.js:427:8)
    at Object.elementFinder.(anonymous function) [as getAttribute] (/Users/danielavalero/workspace/dashboard/node_modules/protractor/lib/protractor.js:62:21)
    at null.<anonymous> (/Users/danielavalero/workspace/dashboard/test/e2e/scenario-login.js:10:48)
    at /Users/danielavalero/workspace/dashboard/node_modules/protractor/jasminewd/index.js:54:12
==== async task ====
    at null.<anonymous> (/Users/danielavalero/workspace/dashboard/node_modules/protractor/jasminewd/index.js:53:12)
    at null.<anonymous> (/Users/danielavalero/workspace/dashboard/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Finished in 14.027 seconds
1 test, 1 assertion, 1 failure
DanielaValero commented 10 years ago

If it helps, when running the elementexplorer.js and trying to perform an action over an element. i.e:
element(by.xpath('//button[contains(@style,"opacity")]')).click()

It throws: There was a webdriver error: undefined undefined

it works ok when disabling the sync

juliemr commented 10 years ago

I've updated Protractor's test suite to use Angular 1.2.9, so this is not an Angular version problem. Have you check out these resources for timeouts?

DanielaValero commented 10 years ago

I've checked with the FAQ's and used the debugger and still get the issue. When using: browser.ignoreSynchronization = true; it works. I'd like to understand better, but really don't get where is the error

kentskinner commented 10 years ago

Daniela, I was seeing the same problem until I realized that I needed to set protractor.getInstance().rootEl to the selector of the element where ng-app is applied. Are you applying ng-app to a descendant of body?

DanielaValero commented 10 years ago

Hi Kent, I am applying the ng-app to the html tag and in the config I set the rootElement to html as well.

juliemr commented 10 years ago

Maybe this is a native webdriver error - the ElementExplorer problem looks suspicious.

Can you try upgrading to the latest version, and making sure you've run webdriver-manager update (or have the latest version in some other way)?

juliemr commented 10 years ago

Haven't heard anything for a while - can this issue be closed?

DanielaValero commented 10 years ago

yes

fabrik42 commented 10 years ago

@DanielaValero how did you resolve your problem? It seems like I'm facing the same (same error, same use case, same ng root element)

ryanirilli commented 9 years ago

same issue here as well. ng-app is on html and rootElement is set to 'html' in my protractor config