Nightwatch TypeError:无法读取null的属性“ message”

时间:2019-04-11 19:25:12

标签: typescript nightwatch.js

Error Message on console:

TypeError: Cannot read property 'message' of null
    at Object.<anonymous> 
    at Object.<anonymous> (
    at HttpRequest.<anonymous> 
    at emitTwo (events.js:)
    at HttpRequest.emit (events.js:)
    at HttpRequest.<anonymous> (
    at emitThree (events.js:1)
    at HttpRequest.emit (events.js:)
    at IncomingMessage.<anonymous> 

**getMyMethod is calling from different class with correct parameter.** 

我的代码:

async function setMyMethod(val) {
    this.myVal = val;
}

async function getMyMethod(newValue) {
    await this.funcName(newValue,"value2");
    return this.myVal;
}

async function funcName(value1,value2) {
    let localvalue1 = value1;
    let localvalue2 =  value2 ;
    await driver.execute( function (localvalue1,localvalue2) {
            let testValue = localvalue2;
            switch (localvalue1) {
                case "conditionValue":
                    return testValue.something; //**(I AM NOT ABLE TO CALL THIS)**
                default:
                    console.log("some log");
                    break;
            }
        }, [localvalue1, localvalue2], function (result) {
            switch (localvalue1) {

                case "conditionValue":
                    base.setMyMethod(result.value);
                    break;
                default:
                    break;
            }
            driver.assert.equal("some condition");
        });

如果我在“ funcName”下为 let testValue =“ hardValue” 提供硬编码的值,则可以执行代码,但不会使用我的参数。 如上所述,给我“空”错误。

0 个答案:

没有答案