TypeError:无法读取未定义的属性“textToBePresentInElementValue”

时间:2015-12-02 01:02:34

标签: javascript python selenium webdriver protractor

我正在尝试在我使用量角器编写的非角度应用程序脚本上应用预期条件,我正在尝试等待状态消息并抓住它但不起作用并抛出错误:

  

TypeError:无法读取未定义的属性'textToBePresentInElementValue'

这是我的代码:

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; 

1 个答案:

答案 0 :(得分:1)

Expected conditions are coming from protractor全局对象,而不是browser。替换:

var EC = browser.ExpectedConditions;

使用:

var EC = protractor.ExpectedConditions;