【发布时间】:2018-11-19 10:58:33
【问题描述】:
我正在我的 Angular 应用程序中使用 jasmine runner 实现 Protrator 框架。我单击具有预期结果的每个元素。现在我的应用程序中有一个公司列表。每个公司都有两三台机器是边吧。我实现了两个 for 循环,它们也通过公司和机器循环。现在在一个机器列表中有一个错误,因此显示来自本地主机的警报。由于这个原因,循环中断并失败。我想在那里实现一个条件,以便它可以检测到条件并从循环中继续。但我无法理解如何实现它。
我的测试代码
for (let company = 0; company < await companyOption.count(); company++) {
await companyOption.get(company);
for (let machine = 0; machine < await machineList.count(); machine++) {
await click.onto(machineList.get(machine));
if (window.alert()) {
//here i want to implement if browser.switchto.alert() is appear then test should be continue to next loop
} else {
await expect(machineList.get(machine).isSelected());
}
.................... other code
}
打字稿中的警报代码
ngOnInit() {
this.route.paramMap.switchMap((params: ParamMap, index) => this.machineService.load(parseInt(params.get("machineId")))).subscribe(machine => {
this.machine = machine;
if (this.machine.type === null)
window.alert("No machine type assigned for " + this.machine.name + "\nAssign a type to view the details.");
});
}
【问题讨论】:
标签: javascript angular jasmine protractor