只有Else正在执行,甚至“结果”也不正确

时间:2019-02-04 07:46:01

标签: typescript protractor

我做了一个定位器,指示禁用按钮,并将其置于类似状态,刷新页面,如果result为true,则在else中等待15秒,如果result为true,则执行if语句。但是它会继续执行else语句。

static async waitForButtonToBeEnabledAndThenClickToDownload(id: string, classAttr: string) {
    await ElementHelper.isElementDisplayed(CompliancePolicyManagementPage.locatorByIdAndDisabledAttribute(id)).then(function (result) {
        for (var i = 0; i <= 10; i++) {
            if (result != true) {
                CommonPageHelper.clickByIdandClass(id, classAttr);
                WaitHelper.getInstance().staticWait(1000);
                console.log('Value of Result should be false: ' + result);
                break;
            }
            else {
                WaitHelper.getInstance().staticWait(15000);
                CommonPageHelper.refreshPage();
                console.log('Value of Result: ' + result);
            }
        }
    });
}

如果结果为true,则将执行else语句;如果结果为true,则将执行if语句,并应终止函数

1 个答案:

答案 0 :(得分:0)

尝试以下一个

Remote ICE candidate received {candidate: "candidate:1 2 UDP 2013266430 172.17.0.2 6004 typ host", component: undefined, foundation: undefined, ip: undefined, port: undefined, …}
jsonrpcclient.js:146 Received request: {"method":"iceCandidate","params":{"endpointName":"puld42tsstkztcho","sdpMLineIndex":0,"sdpMid":"0","candidate":"candidate:2 2 TCP 1015021822 172.17.0.2 9 typ host tcptype active"}}
WebRtcPeer.ts:298 Remote ICE candidate received {candidate: "candidate:2 2 TCP 1015021822 172.17.0.2 9 typ host tcptype active", component: undefined, foundation: undefined, ip: undefined, port: undefined, …}
jsonrpcclient.js:146 Received request: {"method":"iceCandidate","params":{"endpointName":"puld42tsstkztcho","sdpMLineIndex":1,"sdpMid":"1","candidate":"candidate:2 2 TCP 1015021822 172.17.0.2 9 typ host tcptype active"}}
WebRtcPeer.ts:298 Remote ICE candidate received {candidate: "candidate:2 2 TCP 1015021822 172.17.0.2 9 typ host tcptype active", component: undefined, foundation: undefined, ip: undefined, port: undefined, …}
WebRtcStats.ts:86 WebRtc stats not enabled
2jsonrpcclient.js:183 Response: {"sessionId":"k0s2bv7dut5enqhsbn00o4hn6s"}
jsonrpcclient.js:146 Received request: {"method":"iceCandidate","params":{"endpointName":"puld42tsstkztcho","sdpMLineIndex":1,"sdpMid":"1","candidate":"candidate:3 2 TCP 1010827518 172.17.0.2 4295 typ host tcptype passive"}}
WebRtcPeer.ts:298 Remote ICE candidate received {candidate: "candidate:3 2 TCP 1010827518 172.17.0.2 4295 typ host tcptype passive", component: undefined, foundation: undefined, ip: undefined, port: undefined, …}
jsonrpcclient.js:146 Received request: {"method":"iceCandidate","params":{"endpointName":"puld42tsstkztcho","sdpMLineIndex":0,"sdpMid":"0","candidate":"candidate:3 2 TCP 1010827518 172.17.0.2 4295 typ host tcptype passive"}}
WebRtcPeer.ts:298 Remote ICE candidate received {candidate: "candidate:3 2 TCP 1010827518 172.17.0.2 4295 typ host tcptype passive", component: undefined, foundation: undefined, ip: undefined, port: undefined, …}
2jsonrpcclient.js:183 Response: {"sessionId":"k0s2bv7dut5enqhsbn00o4hn6s"}
StreamManager.ts:126 Your local 'Stream' with id [puld42tsstkztcho_CAMERA_XMVGR] video is now playing

希望它对您有帮助