gpt4 book ai didi

javascript - 为什么 Testcafe 忽略 If Else If 语句的第一个条件

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:53:45 25 4
gpt4 key购买 nike

我的申请中有以下安全问题

  1. 您的第一个电话号码是什么?
  2. 你最喜欢什么颜色?
  3. 你最喜欢的运动队是谁?

下面是部分代码

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com