赛普拉斯 - 带有页面对象的链方法返回
我用某些链条方法实现了页面对象。
页面看起来像这样
class Table {
getTable() {
return cy.get('table#tblItem');
}
getListRow() {
return this.getTable()
.within(($tbl) => {
cy.get('tbody').scrollTo('bottom', { ensureScrollable: false, duration: 1000 });
return cy.wrap($tbl).find('tbody#itemBody tr');
});
}
}
,在柏树规范文件中,我确实断言要验证行列表是否具有项目,
Table.getListRow()
.then((lstRowItem) => {
expect(lstRowItem).have.length.greaterThan(1);
})
但我总是得到方法'getTable()''而不是'getlistrow()'的结果。该测试失败了,因为它获得了表的值1。
如何获得此链方法的正确回报。
谢谢
I implemented page objects with some chain methods.
Page looks like this
class Table {
getTable() {
return cy.get('table#tblItem');
}
getListRow() {
return this.getTable()
.within(($tbl) => {
cy.get('tbody').scrollTo('bottom', { ensureScrollable: false, duration: 1000 });
return cy.wrap($tbl).find('tbody#itemBody tr');
});
}
}
And in cypress spec file, I do assertion to verify if the row list has items
Table.getListRow()
.then((lstRowItem) => {
expect(lstRowItem).have.length.greaterThan(1);
})
But I always get the result of method 'getTable()', not 'getListRow()'. The test failed because it gets value 1 of the table.
How can I get correct return of this chain method.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.within()
命令将不允许返回内部值。使用
。
参考:。
The
.within()
command will not permit returning of the inner value.Use a
.then()
and.find()
instead.Ref: .within()