Protractor Serenity/JS:为什么See.if中的断言有时返回空字符串?
我面临See.if()的问题-它有时返回空字符串 使用的技术堆栈:Protractor Serenity/JS:为什么See.if中的断言有时返回空字符串?,protractor,cucumber,angular5,primeng,serenity-js,Protractor,Cucumber,Angular5,Primeng,Serenity Js,我面临See.if()的问题-它有时返回空字符串 使用的技术堆栈: 宁静/JS配黄瓜和量角器 P-Growl-启动咆哮组件 柴如约-期望法 以下是错误:断言错误:预期“”包含“操作成功” 步骤。ts this.Then(/^he should see the user (.*) success message$/, (severity) => { browser.waitForAngularEnabled(false); // Workaround fix for p-growl
this.Then(/^he should see the user (.*) success message$/, (severity) => {
browser.waitForAngularEnabled(false); // Workaround fix for p-growl
return stage.theActorInTheSpotlight().attemptsTo(
Messages.called(severity)
);
});
import { PerformsTasks, Task, Enter, Click, See, Is, Wait, Text } from 'serenity-js/protractor';
import { expect } from '../utils/expect';
import { ListUI } from '../components/ui';
export class Messages implements Task {
constructor(private severity: string) { }
static called(severity: string) {
return new Messages(severity);
}
performAs(actor: PerformsTasks): PromiseLike<void> {
if (this.severity.toLowerCase() === 'success') {
return actor.attemptsTo(
Wait.until(ListUI.message, Is.present()),
See.if(
Text.of(ListUI.message),
actual => expect(actual).to.eventually.include('Operation Success')
),
Click.on(ListUI.messageCloseWidget)
);
}
}
}
import { Target, Text } from 'serenity-js/protractor';
import { by } from 'protractor';
export class ListUI {
static message = Target.the('Message Widget')
.located(by.id('messages'));
static messageCloseWidget = Target.the('Message Close Widget')
.located(by.css('#messages .ui-growl-icon-close'));
}
任务。ts
this.Then(/^he should see the user (.*) success message$/, (severity) => {
browser.waitForAngularEnabled(false); // Workaround fix for p-growl
return stage.theActorInTheSpotlight().attemptsTo(
Messages.called(severity)
);
});
import { PerformsTasks, Task, Enter, Click, See, Is, Wait, Text } from 'serenity-js/protractor';
import { expect } from '../utils/expect';
import { ListUI } from '../components/ui';
export class Messages implements Task {
constructor(private severity: string) { }
static called(severity: string) {
return new Messages(severity);
}
performAs(actor: PerformsTasks): PromiseLike<void> {
if (this.severity.toLowerCase() === 'success') {
return actor.attemptsTo(
Wait.until(ListUI.message, Is.present()),
See.if(
Text.of(ListUI.message),
actual => expect(actual).to.eventually.include('Operation Success')
),
Click.on(ListUI.messageCloseWidget)
);
}
}
}
import { Target, Text } from 'serenity-js/protractor';
import { by } from 'protractor';
export class ListUI {
static message = Target.the('Message Widget')
.located(by.id('messages'));
static messageCloseWidget = Target.the('Message Close Widget')
.located(by.css('#messages .ui-growl-icon-close'));
}
请帮帮我。提前感谢。在Wait.until()之前,尝试Wait.for(持续时间为秒(5))
我通过提供primeng咆哮消息选择器解决了这个问题 为消息(#messages.ui咆哮消息)提供了精确的选择器 以下代码已修复:
import { Target, Text } from 'serenity-js/protractor';
import { by } from 'protractor';
export class ListUI {
static message = Target.the('Message Widget')
.located(by.css('#messages .ui-growl-message'));
static messageCloseWidget = Target.the('Message Close Widget')
.located(by.css('#messages .ui-growl-icon-close'));
}
如果我去等待,那么等待在内部做什么?