4

我想知道 Javascript (NodeJS) 中是否有一个用于Protractor的框架,它支持一种干净的方式来定义页面对象上的页面对象元素,就像site_prism一样。我已经检查了星盘,但不太符合目的。

这就是使用site_prism声明性定义页面对象的方式

class Home < SitePrism::Page
  set_url "/index.htm"
  set_url_matcher /google.com\/?/
  element :search_field, "input[name='q']"
  element :search_button, "button[name='btnK']"
  elements :footer_links, "#footer a"
  section :menu, MenuSection, "#gbx3"
end

class MenuSection < SitePrism::Section
  element :search, "a.search"
  element :images, "a.image-search"
  element :maps, "a.map-search"
end

有谁知道或已经开发了类似上述的解决方案,但对于Protractor。也许有人在内部使用自定义框架,你愿意开源吗?

关于星盘它缺乏集合支持,我正在寻找一种更具声明性的语法;代替

username: { get: function() { return this.findElement(this.by.input('username')); },

我期待一些更具声明性的东西,例如:

username: By.input('username'),

可以在这里进一步挖掘缺少的星盘功能,但我的问题不是星盘本身,而是关于 JS 是否有更好的site_prism等价物。

注意:从软件质量保证和测试迁移问题,因为那里没有得到足够的关注。

4

2 回答 2

0

我使用这种模式(更干净一点):

'use strict'
exports.MyClassPage = function() {

  var textName = element(by.id("name"));
  var tabUsers = element.all(by.repeater("user in users"));

  this.setTxtName = function(name) {
    return textName.sendKeys(name);
  };
}
于 2015-06-12T15:38:32.540 回答
0

我正在使用这个npm 包来声明页面对象选择器。例如,site_prism代码如下所示:

const po = require('@vitalets/page-object');

const menuSection = exports.menuSection = po`.menu`;
menuSection.search = po`a.search`;
menuSection.images = po`a.image-search`;
menuSection.maps = po`a.map-search`;
于 2019-11-10T07:38:41.370 回答