我的申请中有以下安全问题
- 您的第一个电话号码是什么?
- 你最喜欢什么颜色?
- 你最喜欢的运动队是谁?
下面是部分代码
export default class webPage {
constructor () {
this.securityQuestion = Selector('#challengeQuestionLabelId');
this.sportQuestion = this.securityQuestion.withText('sports');
this.colorQuestion = this.securityQuestion.withText('color');
this.phoneQuestion = this.securityQuestion.withText('phone');
}
}
条件语句
async answerSecurityQuestion() {
var myAnswer;
if ( await this.webPage.colorQuestion.exists ) {
myAnswer = "color1";
} else if ( await this.webPage.phoneQuestion.exists ) {
myAnswer = "phone1";
} else {
myAnswer = "sports1";
}
问题出在第一个 if 语句上。即使问题包含“颜色”,代码也不会首先识别问题。
我调换了语句的顺序,发现问题不在于选择器,而在于第一个 if 语句。
有谁知道如何解决这个问题?
最佳答案
添加下面的 await 语句解决了这个问题。
await t.wait(3000);
关于javascript - 为什么 Testcafe 忽略 If Else If 语句的第一个条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52571488/