【问题标题】:Protractor e2e test Angular UI grid Cell fillingProtractor e2e 测试 Angular UI 网格单元格填充
【发布时间】:2016-11-14 12:23:42
【问题描述】:

在 UI-Grid 的 Protractor e2e 测试中,我使用了 ui.grid.e2eTestLibrary.api:gridTest 中提供的函数 dataCell(gridId, fetchRow, fetchCol),

来源:-https://github.com/angular-ui/ui-grid/tree/master/test/e2e

dataCell: function( gridId, fetchRow, fetchCol ) {
var row = this.getGrid( gridId ).element(by.css('.ui-grid-render-container-body')).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( fetchRow )  );
return row.element( by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name').row( fetchCol ));}

评论部分明确提到,dataCell(fetchRow,fetchColumn) 必须在页面中可见,才能访问数据单元格并填充它。

@param {string} gridId 要检查的网格的 id

@param {integer} fetchRow 要返回的行号(在可见行内)

@param {integer} fetchCol 列数(可见列内) 你想退货

我有一个较大的 UI 网格(约 100 行和约 50 列),因此所有行和列都不可见。因此,为了在量角器自动测试期间使它们在页面中可见,我修改了 dataCell() 的代码如下:-

dataCell: function( gridId, fetchRow, fetchCol ) {

var row = this.getGrid( gridId ).element( by.css('.ui-grid-render-container-body')).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( fetchRow )  );
browser.executeScript("arguments[0].scrollIntoView(true);", row.getWebElement());

return row.element( by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.uid').row( fetchCol ));

},

在此之后,它应该滚动到适当的单元格,然后选择它,并进行相应的编辑。

但是,我得到的 dataCell 是可点击的(),但是当我通过方法提供输入时:-

cell.element(by.css("input")).sendKeys("Data to be filled");

Protractor 崩溃了,显示的错误如下:-

Failed: No element found using locator: By(css selector, input).

请建议一种方法,在 UI-grid 中编辑网格单元格,这些单元格通过适当的滚动是不可见的。

采取的其他措施:-

我使用了一种渲染行和列的解决方法,即在创建 UI 网格的开发人员代码中增加 virtualizationThreshold 和 columnvirtualizationThreshold 的值。单元定位正确,但现在遇到了性能问题。 RAM 和交换完全被自动化过程消耗,因此过程变得太慢。有什么办法可以解决内存性能问题?

【问题讨论】:

    标签: javascript angularjs jquery-ui angular-ui-grid


    【解决方案1】:

    虚拟化数据的自动化 e2e 测试很难。要找到它,它必须在 DOM 中,要进入 DOM,您必须滚动到它。因此你需要循环使用你的查找器:find/scroll/find/scroll;并且仅在您匹配或用完滚动空间时才爆发。希望我错了,但我在 ui.grid.e2eTestLibrary.api:gridTest 中看不到任何执行此操作的内容。

    【讨论】:

      猜你喜欢
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      相关资源
      最近更新 更多