页面上有以下DOM
<button type="submit" ng-reflect-disabled="true" disabled="">
Save & Exit
</button>此外,我还有一个(屏幕播放)组件来针对它的属性
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);
}我想要做的就是确保DOM标记了禁用的属性,但是下面在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("");
});基本我对如何使用属性问题定位任何属性没有足够的疑问。
此外,我也没有找到它的任何用例,任何建议,提示都将是非常感激的。
发布于 2017-09-21 21:16:46
你在正确的轨道上!您只需告诉Serenity/JS您感兴趣的属性。
Attribute问题的语法是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('');或者更好的是,使用任务来看见
return actor.attemptsTo(
See.if(Attribute.of(CreateClientComponent.saveAndExit).called('disabled'), value => expect(value).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),
)希望这能有所帮助!
1月
https://stackoverflow.com/questions/46345827
复制相似问题