Using Protractor Test with Bootstrapped AngularJS

后端 未结 1 953
北荒
北荒 2020-12-09 05:18

I want to be able to test my Angular application with Protractor. Since I use RequireJS, I cannot use ng-app directive in my DOM and that is why I bootstrap Ang

相关标签:
1条回答
  • 2020-12-09 05:54

    go to protractor confiuration and add this

    onPrepare: function() {
    // implicit and page load timeouts
      browser.manage().timeouts().pageLoadTimeout(40000);
      browser.manage().timeouts().implicitlyWait(25000);
    
      // for non-angular page
      browser.ignoreSynchronization = true;
    
      // sign in before all tests
    
    }
    

    It worked for me

    my full config file looks like this...

    // conf.js
    exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['../**/*.e2e.js'],
    multiCapabilities: [{
    browserName: 'firefox'
    }],
    
    onPrepare: function() {
    // implicit and page load timeouts
    browser.manage().timeouts().pageLoadTimeout(40000);
    browser.manage().timeouts().implicitlyWait(25000);
    
    // for non-angular page
    browser.ignoreSynchronization = true;
    
    // sign in before all tests
    
     }
    }
    

    What actually happens is that you ask from protractor to wait for an amount of time and ignnore the document.ready(), in order to give you time to bootstrap angular manually.

    0 讨论(0)
提交回复
热议问题