'protractor, on login form sendkeys() are not working. Browser don't displays my value for the form fields

(I'm not using jQuery) Hi! I'm starting with protractor and cucumber and i'm testing a login page. I'm trying to insert values on a form for the login, but when i lunch the configuration file to lunch the test, Chrome open the login page but don't displays the values that i setted for the required fields. Clicking on sumbit button, the page should be redirect to another. Can anyone help me? How i have to change my step definition file to make it works? Thank you

I think that there are some problems like in configuration and others. Here is step definition:

 This is my new step definition file:

    Given("I'm on site login page", function () {
            //return pending;
            browser.driver.get('https://www.websiteurl.com/login.html');
            browser.sleep(20000);
            });     

When('I see the submit-button', function () {
        // Write code here that turns the phrase above into concrete actions
        //var sumbit = browser.executeScript('document.getElementById("submit-//wrap.cf.input-formFields")');
 var sumbit = element(by.css('.submit-wrap.cf.input-formFields'));
        expect(sumbit).to.not.be.null;
      });

     When('I filled all the mandatory fields', function () {
            // Write code here that turns the phrase above into concrete actions
              window.onload = function(){
                  var bookingNumberField = browser.executeScript('document.getElementById("variation2-bookingNumber").getText()');
                  var firstNameField = browser.executeScript('document.getElementById("variation2-firstName").getText()');
                  var lastNameField = browser.executeScript('document.getElementById("variation2-lastNameField").getText()'); 
                  var dobMonth = browser.executeScript('document.getElementById("month").getText()'); 
                  var dobDay = browser.executeScript('document.getElementById("day").getText()'); 
                  var dobYear = browser.executeScript('document.getElementById("year").getText()');
                //  var firstNameField = document.getElementById("variation2-firstName");
                //      var lastNameField = document.getElementById("variation2-lastName");
                   //   var dobMonth = document.getElementById("month");
                  //    var dobDay = document.getElementById("day");
                  //    var dobYear = document.getElementById("year");
                      browser.sleep(1000);
                      //browser.waitForAngular();
                      //browser.executeScript to cut eventually
                      browser.executeScript.bookingNumberField.clear().sendKeys('WJXMHH');
                     browser.executeScript.firstNameField.clear().sendKeys('Mark');
                    browser.executeScript.lastNameField.clear().sendKeys('Altria');
                      element(by.cssContainingText('option', 'March')).click();
                      element(by.cssContainingText('option', '10')).click();
                      element(by.cssContainingText('option', '1991')).click();
                      TermsChkbxLabel = element(by.css("label[for='checkboxb']"));
                      TermsChkbxLabel.click(); 
              }
          }); //loginBtn.click();

     Then('I am able to click on it to login', function () {

   //       var ptor = protractor.getInstance();
   //       ptor.ignoreSynchronization = true;
   //       var login_b = browser.executeScript('document.getElementById("login-button").click()');
            //var login_b = document.getElementsByClassName("login-button").click();
    //          ptor.sleep(10000); 
    //          var expectedUrl = ptor.getCurrentUrl();
    //          //expect(expectedUrl).toEqual('https://www.websiteurl.com/newpage.html');

           });

     Then('I am able to open the new page', function () {

    var login_b = element(by.css('.login-button'));
            login_b.click();
    //      var ptor = protractor.getInstance();
    //      ptor.ignoreSynchronization = true;
    //      var login_b = document.getElementsByClassName("login-button").click();
    //       ptor.sleep(10000); 
    //       var expectedUrl = ptor.getCurrentUrl();
    //       


        });

Here is the protractor conf.js:

var seleniumServer = require('selenium-server')
var nightwatchCucumber = require('nightwatch-cucumber')
require('babel-core/register');

var nightwatchCucumberConf = {
    runner: 'nightwatch',
    featureFiles: 'features',
    stepDefinitions: 'features/step_definitions/testing_1_6.js',
    closeSession: 'afterFeature'
};

exports.config = {
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    getPageTimeout: 60000,
    allScriptsTimeout: 500000,
    framework: 'custom',
    // path relative to the current config file
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    plugins: [{
        path: require.resolve('protractor-console'),
        logLevels: ['severe']
    }],

    directConnect: true, //chrome only

    jasmineNodeOpts: {},

    onPrepare: function() {},
    capabilities: {
        'browserName': 'chrome'
    },

    // Spec patterns are relative to this directory.
    specs: [
        'features/*.feature'
    ],

    baseURL: 'https://www.websiteurl.com/login.html',

    cucumberOpts: {
        //require: 'features/step_definitions/**/*.js',
        require: 'features/step_definitions/testing_1_6.js',
        tags: false,
        // format: 'pretty',
        profile: false,
        'no-source': true
    }
};

I have this error too: [12:57:27] E/launcher - 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" [12:57:27] E/launcher - Error: 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.



Solution 1:[1]

Step definition file testing_1_6.js:

// chai is an assertion library
var chai = require('chai'); 
// chai-as-promised is an helper to handle promise
var chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised); 
expect = chai.expect;

Given("I'm on site login page", function() {
    browser.driver.get('https://www.websiteurl.com/login.html');
    return browser.sleep(20000);
});

When('I see the submit-button', function() {
    var sumbitBtn = element(by.css('.submit-wrap.cf.input-formFields'));
    return expect(sumbitBtn.isDisplayed()).to.eventually.be.true;
});

When('I filled all the mandatory fields', function() {
    element(by.id('variation2-bookingNumber')).sendKeys('WJXMHH');
    element(by.id('variation2-firstName')).sendKeys('Mark');
    element(by.id('variation2-lastNameField')).sendKeys('Altria')
    element(by.cssContainingText('#month > option', 'March')).click();
    element(by.cssContainingText('#day > option', '10')).click();
    element(by.cssContainingText('#year > option', '1991')).click();
    return element(by.css("label[for='checkboxb']")).click();
}); 

Then('I am able to click on it to login', function() {
    return element(by.id('login-button')).click();
});

Then('I am able to open the new page', function() {
    var newPageUrl = 'https://www.websiteurl.com/newpage.html';
    browser.sleep(10000); 
    return expect(browser.getCurrentUrl()).to.eventually.equal(newPageUrl);
});

protractor conf.js:

exports.config = {
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    getPageTimeout: 60000,
    allScriptsTimeout: 500000,

    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),

    plugins: [{
        path: require.resolve('protractor-console'),
        logLevels: ['severe']
    }],

    directConnect: true, //chrome only

    onPrepare: function() {
        browser.ignoreSynchronization = true;
    },

    capabilities: {
        browserName: 'chrome'
    },

    specs: [
        'features/*.feature'
    ],

    cucumberOpts: {
        require: [
            'features/step_definitions/testing_1_6.js'
        ]
    }
};

Solution 2:[2]

browser.waitForAngularEnabled(false);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 chithrashree yc