mercredi 25 mai 2016

Protractor: Async timing out, I think because it won't find an element

I've been trying to figure out this error for most of the day. 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. Thanks for any help or advice.

Aucun commentaire:

Enregistrer un commentaire