(Appium - JavaScript - Mocha - Promises)返回“{state:'pending'}”而不是元素文本

时间:2015-07-13 23:06:04

标签: javascript promise mocha appium chai-as-promised

我正在尝试访问此元素中的文本。无论何时我获得函数的返回值或将结果存储在变量中,我都会在打印到控制台时获得“{state:'pending'}”有没有人知道我做错了什么?请原谅我的无知。

describe('End to End for Single Declined Applicant', function endToEnd(){
var browser;
//Initialize session
    before('Establishing Server Connection', function establishConnection(){
        browser = wd.promiseChainRemote("127.0.0.1", 4723)
        return browser.init(desired)
        .then(function goodConnection(){
            console.log("Connection Established")
        },function badConnection(){
            console.log("Connection Failed")
        });
    });

    describe('Login Page', function loginPage(){
    it('should login with valid credentials', function interactWithPage(){
        this.timeout(maxWait)
        //Check if element is available
        return browser.waitForElementById(objectRepo.loginObjects.androidUserIdField, wait, pollRate)
        .then(function enterUserId(){
            //Input text
            return browser.elementById(objectRepo.loginObjects.androidUserIdField).type(objectRepo.myInputs.userId)
        })
        .then(function getUserId(){
              //Get text from attribute
            return browser.elementById(objectRepo.loginObjects.androidUserIdField).getAttribute("text")
        })
        .then(function fulfilledPromise(){
            console.log(getUserId())
            console.log("Working")
        },function rejectedPromise(){
            //If promise in the chain is rejected
            console.log("Not Working")
        })
    });
});

0 个答案:

没有答案