TypeError:无法读取属性'text显示元素值'的未定义

TypeError: Cannot read property 'textToBePresentInElementValue' of undefined

本文关键字:元素 显示 未定义 text 读取 属性 TypeError      更新时间:2023-09-26

我正试图将预期条件应用于我用量角器编写的非角度应用程序脚本,我正试图等待状态消息并获取它,但不起作用并抛出错误:

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; 

预期条件来自protractor全局对象,而不是browser。替换:

var EC = browser.ExpectedConditions;

带有:

var EC = protractor.ExpectedConditions;