Serenity js 如果元素被禁用,如何使用serenity js属性断言
我在页面上有以下DOMSerenity js 如果元素被禁用,如何使用serenity js属性断言,serenity-js,Serenity Js,我在页面上有以下DOM <button type="submit" ng-reflect-disabled="true" disabled=""> Save & Exit </button> 我所要做的就是确保DOM标记了disabled属性,但是我在step_definitain文件中的以下尝试毫无结果 this.Then( /^he should see "Save & Exit" button still is disable
<button type="submit" ng-reflect-disabled="true" disabled="">
Save & Exit
</button>
我所要做的就是确保DOM标记了disabled属性,但是我在step_definitain文件中的以下尝试毫无结果
this.Then(
/^he should see "Save & Exit" button still is disabled$/,
function(buttonText) {
return expect(
this.stage.theActorInTheSpotlight().toSee(CreateClientComponent.saveAndExitAttribute),
).to.equal("");
});
基本上,我没有足够的详细说明如何使用
而且我也没有找到它的任何用例,任何建议和提示都将非常感谢您走在正确的轨道上!您只需要告诉Serenity/JS您感兴趣的属性
属性
问题的语法是Attribute.of(target).called('Attribute name')
,根据
因此,与其说:
import {Attribute, Target} from "serenity-js/lib/serenity-protractor";
import {by} from "protractor";
export class myComponent {
public static saveAndExit = Target.the('"Save & Exit" submit button')
.located(by.buttonText("Save & Exit"));
public static saveAndExitAttribute = Attribute.of(CreateClientComponent.saveAndExit);
}
试试这个:
export class myComponent {
public static saveAndExit = Target.the('"Save & Exit" submit button')
.located(by.buttonText("Save & Exit"));
}
然后在你的断言中:
return expect(
actor.toSee(
Attribute.of(CreateClientComponent.saveAndExit).called('disabled')
)
).to.eventually.equal('');
或者更好,使用任务来:
然后可以将其提取到另一个任务中:
const CheckIfTheButtonIsDisabled = (button: Target) => Task.where(`#actor checks if the ${button} is disabled`,
See.if(Attribute.of(button).called('disabled'), value => expect(value).to.eventually.equal('')
);
这将使您的断言简化为:
return actor.attemptsTo(
CheckIfTheButtonIsDisabled(CreateClientComponent.saveAndExit),
)
希望这有帮助
一月
const CheckIfTheButtonIsDisabled = (button: Target) => Task.where(`#actor checks if the ${button} is disabled`,
See.if(Attribute.of(button).called('disabled'), value => expect(value).to.eventually.equal('')
);
return actor.attemptsTo(
CheckIfTheButtonIsDisabled(CreateClientComponent.saveAndExit),
)