【发布时间】:2017-09-25 16:05:56
【问题描述】:
我在 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 中起作用
【问题讨论】:
标签: javascript intern leadfoot