简体   繁体   中英

Protractor e2e test Angular UI grid Cell filling

In Protractor e2e testing for UI-Grid, I am using the function dataCell( gridId, fetchRow, fetchCol ), which has been provided in ui.grid.e2eTestLibrary.api:gridTest,

Source :- 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 ));}

It is clearly mentioned in the comment section, that the dataCell(fetchRow,fetchColumn) has to be visible in the page, for accessing the data cell and fill it up.

@param {string} gridId the id of the grid that you want to inspect

@param {integer} fetchRow the number of the row (within the visible rows) that you want to return

@param {integer} fetchCol the number of the col (within the visible cols) that you want to return

I am having a large UI grid (~100 rows and ~50 Columns), so all the rows and columns are not visible. So, in order to make them visible in page during automated testing by protractor, I have modified the code of dataCell() as follows :-

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 ));

},

After this, it was supposed to scroll to appropriate cell, and then select it, and edit it accordingly.

But, the dataCell which I am getting, is clickable(), but when I am giving the input by the method :-

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

Protractor is getting crashed, and the error which is displayed is shown below :-

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

Please suggest a method, to edit grid cells in UI-grid, which are not visible by appropriate scrolling.

Addtional Actions Taken :-

I have used a workaround of rendering rows and columns, by increasing the values of virtualizationThreshold and columnvirtualizationThreshold in developers code of creating UI grid. Cells are locating properly, though it is now hitting performance issue. RAM and swap are getting totally consumed by automation process, and subsequently the process is getting too slow. Is there any way, to resolve issue of memory performance ?

Automated e2e testing for virtualized data is hard. To find it, it must be in the DOM, to get into the DOM, you must scroll to it. Therefore you need to use your finder in a loop: find/scroll/find/scroll; and only break out when you match or run out of room to scroll. Hopefully I'm wrong, but I don't see anything in ui.grid.e2eTestLibrary.api:gridTest that does this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM