1

We are re-writing our Angular1 platform in Vue. I am trying to run a simple test but the test is failing because Protractor is trying to sync with the page but cannot because it is not in Angular. Any ideas what needs to be changed so that I can run the tests on the Vue site? In the config file, there aren't any references to waitforAngular.

Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"

This is the core of the config file:

exports.config = { directConnect: true, seleniumAddress: 'http://127.0.0.1:4444/wd/hub', framework: 'jasmine2', capabilities: { 'browserName': 'chrome' }, params: require( './testdata.json' ),

// Creates an XML report of results using Jasmine Reporters
onPrepare: function () {
    browser.get
    var jasmineReporters = require( __dirname + '/node_modules/jasmine-reporters' );
    jasmine.getEnv().addReporter( new jasmineReporters.JUnitXmlReporter( null, true, true ) );
    var SpecReporter = require( 'jasmine-spec-reporter' );
    var AllureReporter = require( 'jasmine-allure-reporter' );
    jasmine.getEnv().addReporter( new AllureReporter( {
        resultsDir: 'allure-results'
    } ) );
  // Disable animations when testing to speed up tests and reduce need for browser.sleep()
    var disableNgAnimate = function () {
        angular
          .module( 'disableNgAnimate', [] )
          .run( ['$animate', function ( $animate ) {
              $animate.enabled( false );
          }] );
    };
    var disableCssAnimate = function () {
        angular
          .module( 'disableCssAnimate', [] )
          .run( function () {
              var style = document.createElement( 'style' );
              style.type = 'text/css';
              style.innerHTML = '* {' +
                  '-webkit-transition: none !important;' +
                  '-moz-transition: none !important' +
                  '-o-transition: none !important' +
                  '-ms-transition: none !important' +
                  'transition: none !important' +
                  '}';
              document.getElementsByTagName( 'head' )[0].appendChild( style );
          } );
    };
    // Add jasmine spec reporter
    jasmine.getEnv().addReporter( new SpecReporter( {displayStacktrace: 'all'} ) );
    // Maximize browser window to avoid icons' invisibility
    browser.driver.manage().window().setSize( 1600, 1200 );
    // Global variables used frequently in tests
    global.EC = protractor.ExpectedConditions;
    global.moment = require( 'moment' );
    global.successMessage = element.all( by.className( 'ui-pnotify-text' ) );
    global.alertTitle = element.all( by.className( 'ui-pnotify-title' ) );
    global.dismissSuccessMessage = element.all( by.className( 'ui-pnotify-closer' ) );
    global.messageContainer = element.all( by.className( 'ui-pnotify-container' ) );
    browser.addMockModule( 'disableNgAnimate', disableNgAnimate );
    browser.addMockModule( 'disableCssAnimate', disableCssAnimate );

    protractor.ActionSequence.prototype.sleep = function ( delay ) {
        var driver = this.driver_;
        this.schedule_( "sleep", function () { driver.sleep( delay ); } );
        return this;
    };

    protractor.ActionSequence.prototype.perform = function () {
        var actions = this.actions_.slice();
        var driver = this.driver_;
        return driver.controlFlow().execute( function() {
            actions.forEach( function( action ) {
                var command = action.command;
                if ( typeof command === "function" )
                    driver.flow_.execute( command );
                else
                    driver.schedule( command, action.description );
            } );
        }, 'ActionSequence.perform' );
    };

    protractor.ActionSequence.prototype.clickAndHold = function ( elm ) {
        return this.mouseDown( elm ).sleep( 3000 ).mouseUp( elm );
    };
},
jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 300000,
    print: function () {}
},`
  • Looks like you found your answer. Don't forget to click the green check mark (you can "accept" your own answer!) to let others know that this question has been resolved. – c32hedge Apr 27 '18 at 14:04
  • There is a time limit until I can accept my own answer. Thanks. @c32hedge – kylokyler Apr 28 '18 at 21:25
  • yeah, after giving browser.waitForAngularEnabled(false); my code is also working fine. – Sudha kalaga Sep 7 '18 at 8:48
3

browser.waitForAngularEnabled(false); needs to be explicitly set in the spec/config files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.