量角器 - 驱动程序返回未定义的值表单函数

时间:2015-11-02 14:19:13

标签: javascript function jasmine undefined protractor

请告知此处可能存在的问题。

在测试结束时正确提供了

userLogin,但密码的值为undefined'。似乎函数takePasswordFromNotification()没有从通知中返回相关值 - 为什么? 流程是在创建帐户后弹出通知暂时出现,并带有分配的登录名和密码,我想从通知中获取登录名和密码(随机生成),以便登出并使用登录系统登录系统。其余代码在此功能中运行良好。

fit('should create new user and log in by his account', function () {
    var userId = Math.random().toString(36).substr(2, 20);
    havingTestUser(userId);
    var userLogin = givenAccountOfUser(userId);
    console.log(userLogin);
    var newPassword = takePasswordFromNotification();
    console.log(newPassword);
    welcomePage.logout('newly created (deleted) account');
    browser.driver.get(browser.params.rootUrl);
    browser.wait(EC.presenceOf(loginPage.userLogin), WAIT_TIMEOUT, 'login input field was not present');
    loginPage.userLogin.sendKeys(userLogin);
    loginPage.userPassword.sendKeys(newPassword);
    dv.sleep(10000);
    clickWithWait(loginPage.signInButton);
    expectVisible(welcomePage.usersButton, 'users button after login by new account');
});

    function givenAccountOfUser(userId) {
        userDetailsPage.goTo(userId);
        browser.executeScript('window.scrollTo(0,0);');
        goToLoginInput();
        var userLogin = Math.random().toString(36).substr(2, 20);
        userDetailsPage.loginInputField.sendKeys(userLogin);
        expectClickable(userDetailsPage.saveAccountButton, 'save account button');
        clickWithWait(userDetailsPage.saveAccountButton);
        expectVisible(userDetailsPage.successNotification, 'success notification');
        return userLogin;
    }

function takePasswordFromNotification() {
    userDetailsPage.successNotification.getText().then(function (text) {
        var expectedPasswordLength = 12;
        var newPassword = text.substring(text.length - expectedPasswordLength, text.length);
        return newPassword;
    });}

0 个答案:

没有答案