Muzamil Abbasi
Muzamil Abbasi

Reputation: 49

TypeError: Cannot read property 'textToBePresentInElementValue' of undefined

I am trying to apply expected condition on a non angular app script that i wrote with protractor, i am trying to wait for status message and grab it but doesn't works and throws the error:

TypeError: Cannot read property 'textToBePresentInElementValue' of undefined

Here's my code:

EditContentTest.js

 "use strict";

    ddescribe( "EditContentTest", function() {

        var EditContentPage = require( "./../pages/EditContentPage.js" ),
            LoginPage = require( "./../pages/LoginPage.js" );

        beforeEach( function() {
            browser.driver.manage().window().maximize();
        enter code here

            LoginPage.logout();
            LoginPage.login();
            EditContentPage.get();
            //browser.ignoreSynchronization = true;

            //.manage().timeouts().implicitlyWait(5000);
        } );


        it( "Should remove existing Slug and Save Content", function() {
            expect( wd.getCurrentUrl() ).toEqual( baseUrl + "/en_us/content/edit/1");

            var EC = browser.ExpectedConditions;

            EditContentPage.clearInputBox( "slug" )

            EditContentPage.saveDraft();

            browser.wait(EC.textToBePresentInElementValue(EditContentPage.getStatus,'Unable to update the existing content'), 5000);


            //expect( EditContentPage.getStatus() ).toEqual( "Unable to update the existing content. Please try again." );

        } );

    } );


EditContentPage.js


"use strict";

var EditContentPage = {
    get: function() {
        wd.get( baseUrl + "/content/edit/1");
    },

    getStatus: function() {
        return wd.findElement( by.className( "error" ) ).getText();
    }
};

module.exports = EditContentPage; 

Upvotes: 1

Views: 727

Answers (1)

alecxe
alecxe

Reputation: 474061

Expected conditions are coming from protractor global object, not browser. Replace:

var EC = browser.ExpectedConditions;

with:

var EC = protractor.ExpectedConditions;

Upvotes: 1

Related Questions