TestCafe是否支持页面对象中的部分(就像Nightwatch一样)?如果没有,我们如何在TestCafe中实现这一



我们有丰富的UI,其中包含许多web元素&UI上的多级元素被划分为多个部分。作为新测试自动化框架评估的一部分,我想看看我们是否可以使用TESTCAFE。目前,我们正在使用Nightwatch(JavaScript(框架,该框架支持页面对象中的Section。现在我们转到TestCafe(JavaScript(框架。有人能给我举一个例子,说明我们如何使用TestCafe在PageObjects中维护SECTIONS吗??如果TestCafe不支持,我们如何在TestCafe中实现同样的功能
NighWatch页面对象(带节(示例:nightwatch.js 中page_objects中的多个级别的节

在TestCafe中,页面模型只是一个JavaScript类(https://devexpress.github.io/testcafe/documentation/guides/concepts/page-model.html#page-模型示例(,这样您就可以创建几个嵌套类来反映您的页面结构。

例如,如果页面上有标题、工具栏和列表对象,则可以为页面模型使用以下代码:

class ListModel {
getItem(i) {
//find an item
}
constructor (selector) {
this.selector = selector;
}
}
class ToolbarModel {
action(){
//perform an action        
}
constructor (selector) {
this.selector = selector;
}
}

class PageModel {    
constructor (selector) {
this.selector = selector;
this.title = selector.find('#tile');
this.toolBar = new ToolbarModel(selector.find('#toolbar'));
this.list = new ListModel(selector.find('#list'));
}
}

相关内容

最新更新