我在 Intern 上为 Web 应用程序编写功能测试。我有一个文件,其中描述了测试中的所有操作,并且还有一个测试,其中调用了这些操作
例如:
有一个 Action.ts 文件
在其中按顺序调用测试中的函数
//1
//open the registration window
openRegistration(): Command<void> {
return Action.openRegistration(this.parent);
}
static openRegistration(command: Command<any>): Command<void> {
return command
// click on the authorization menu
.setPageLoadTimeout (10000)
.get(intern.args.url)
.end()
}
//2
inputTextByCssSelector(selector: string, value: string): Command <void> {
return Input.inputTextByCssSelector(this.parent, selector, value);
}
static inputTextByCssSelector(
command: Command<any>,
selector: string,
value: string
): Command<void> {
return command
.setFindTimeout(10000)
.findByCssSelector(selector)
.click()
.type(value)
.end()
.end()
}
像这样
.then(() => action.openRegistration())
.then(() => input.inputTextByCssSelector(
"input [name = userName]",
intern.args.username
))
.then(() => input.inputTextByCssSelector(
"input [name = password]",
intern.args.password
))
但是当我运行测试时,它会下降。
如果我在 openRegistration 结束时设置显式延迟,例如这样
openRegistration(): Command<void> {
return Action.openRegistration(this.parent);
}
static openRegistration(command: Command<any>): Command<void> {
return command
.setPageLoadTimeout(10000)
.get(intern.args.url)
.sleep(7000)
.end()
}
然后一切正常
为什么不工作setFindTimeout(10000),inputTextByCssSelector但sleep(7000)在openRegistration工作