2

UPDATE #2: Traced back to the web app using $timeout instead of $interval. Explained here http://www.protractortest.org/#/timeouts under waiting for page synchronization

UPDATE: So I threw in browser.ignoreSynchronization=true; browser.sleep(5000);for the second test and it works. Not sure why.... The login page works perfectly without it. Best guess now is that it's a running script so it never finishes synchronizing???? Not really sure why it doesn't synchronize. So more or less, how come I would need to ignore synchronization knowing that the site is angular???????

I'm using Protractor with the Jasmine framework.
Tests have been working up to this point.

I think Protractor cannot find my element and therefore times out.
I can't figure out why it won't find my element as it does perfectly fine in earlier tests.

My conf.js

exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js'],
  allScriptsTimeout: 10000,
  onPrepare: function() {
    var SpecReporter = require('jasmine-spec-reporter');
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
  },
  jasmineNodeOpts: {
    showColors: true,
    isVerbose: true,
    realtimeFailure: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 10000,
    print: function() {}
  }
};

Current spec.js

describe('Authorizing newly created account', function() {
//This test works fine
it('should navigate back to login and login', function() {
    browser.get('website');
    element(by.model('$parent.username')).sendKeys('user');
    element(by.model('$parent.password')).sendKeys('test');
    element(by.buttonText('Login')).click();
}); 
//This one doesn't
it('should navigate to organizations', function() {

    //DOESN'T WORK
    var button = element(by.id('btn_organizations'));
    button.click();

});
});

The snippet of HTML I'm trying to get ("Organization" link)

<li ng-if="user.administrator || user.organizationAdministrator">
        <a ui-sref="organizations"  ng-click="closeNav()" id="btn_organizations">
                <span class="glyphicons glyphicons-tree-structure"></span>
                <span class="hidden-sm"><g:message code="organizations" /></span>
        </a>                        
</li>

I thought since the organizations had a ID I could use it to access it, but Protractor doesn't seem to like it.

I then get the error

-Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL

I really hope this isn't something dumb I'm missing.

Delonous
  • 201
  • 2
  • 5
  • 11

1 Answers1

0

Try all those options, it should work with the call back :

  describe('Authorizing newly created account', function() {
 beforeEach(function(done) {
  done();
  }, 10000);   
//This test works fine
it('should navigate back to login and login', function() {
    browser.get('website');
    element(by.model('$parent.username')).sendKeys('user');
    element(by.model('$parent.password')).sendKeys('test');
    element(by.buttonText('Login')).click();
},10000); 
//This one doesn't
it('should navigate to organizations', function() {

    //DOESN'T WORK
    var button = element(by.id('btn_organizations'));
    button.click();

},10000);
},10000);

Take a look into this question and how i have resolved it : Time out problem

Emna Ayadi
  • 2,430
  • 8
  • 37
  • 77