量角器 - 无法读取EC.textToBePresentInElement的undefined属性绑定

时间:2015-10-16 10:37:56

标签: javascript exception selenium-webdriver protractor

我的规格:

  it('displays user details page of an active user', function () {
        var userDetailsPage = new UserDetailsPage();
        var usersPage = new UsersPage();
        expectVisibilityOf(usersPage.thirdRow, 'element firstRow was not visible ');
        var positionUsersTableThirdRow = usersPage.thirdRowPosition.getText();
        var idUsersTableThirdRow = usersPage.thirdRowId.getText();
        var emailUsersTableThirdRow = usersPage.thirdRowEmail.getText();
        clickWithWait(usersPage.thirdRow);
        browser.wait(EC.elementToBeClickable(userDetailsPage.position.value), WAIT_TIMEOUT, 'element position was not clickable ');
        browser.wait(EC.elementToBeClickable(userDetailsPage.id), WAIT_TIMEOUT, 'element id was not clickable ');
        browser.wait(EC.elementToBeClickable(userDetailsPage.email), WAIT_TIMEOUT, 'element email was not clickable ');

        browser.wait(EC.textToBePresentInElement(userDetailsPage.position, positionUsersTableThirdRow), 5000);
        browser.wait(EC.textToBePresentInElement(userDetailsPage.id, idUsersTableThirdRow), 5000);
        browser.wait(EC.textToBePresentInElement(userDetailsPage.email, emailUsersTableThirdRow), 5000);

        //expect(userDetailsPage.position.value.getText()).toEqual(positionUsersTableThirdRow);
        //expect(userDetailsPage.id.getText()).toEqual(idUsersTableThirdRow);
        //expect(userDetailsPage.email.getText()).toEqual(emailUsersTableThirdRow);
    });

问题是当我使用expect(element.getText()).toEqual();(这些评论的)时,测试工作正常但是对于量角器ExpectedCondition,它失败并显示有关未定义绑定的消息 - Failed: Cannot read property 'bind' of undefined。 这是什么问题?

1 个答案:

答案 0 :(得分:2)

我认为这是一个简单的复制粘贴错误。您需要使用userDetailsPage.position.value代替userDetailsPage.position

positionUsersTableThirdRow.then(function (value) {
    browser.wait(EC.textToBePresentInElement(userDetailsPage.position.value, value), 5000);
});

请注意,我在positionUsersTableThirdRow明确解析then()