I am using ui-grid in my app, and I would like to select row in the grid - ie: programmaticly checkbox a row.
I saw that there are is the file gridTestUtils.spec.js in ui-grid/tests folder ,
I have copied it into my tests/lib folder.
Now how can I use it to select a row in my grid?
I hope you can help
I was able to select a row element by first defining a page object as so:
'use strict';
var AngularPage = function () {
};
AngularPage.prototype = Object.create({}, {
videoListGrid: { get: function () { return element(by.css('div[ui-grid="videoListGridOptions"]')); }},
uiGridCell: { get: function () { return element(by.css('.ui-grid-cell')); }},
});
module.exports = AngularPage;
Now that these page objects are defined, here is the test:
var gridId = null;
var viewVideoPage = require('./../pages/viewVideo.page.js'); //define the page object
/**
* make sure to bring in the gridTest utility library
https://github.com/angular-ui/ui-grid/blob/master/test/e2e/gridTestUtils.spec.js
*/
var gridUtils = require('./../lib/gridTestUtils.spec.js');
describe('MEP-1023 Test the Video Tags Feature for user MANAGER', function () {
var page;
beforeEach(function () {
page = new viewVideoPage();
});
it('should get the grid id and checkbox the first row', function () {
page = new videoListPage();
expect(page.videoListGrid.isPresent()).toBe(true);
//now get the gridId
page.videoListGrid.getAttribute('class').then(
function (classes) {
var classArr = classes.split(" ");
console.log(classArr.length);
_.each(classArr, function (theClass) {
//find the class that starts with grid, and grab the gridId which we can use to refer
//to the various rows
if (theClass.substr(0, 4) === "grid") {
gridId = theClass;
console.log();
}
});
gridUtils.getRow(gridId, 0).click();
}
);
});
});