我在我的应用程序中使用ui-grid,我想在网格中选择行 - 即:在程序上选中一行。
我看到ui-grid / tests文件夹中有文件gridTestUtils.spec.js,
我已将其复制到我的tests / lib文件夹中。
现在我如何使用它来选择网格中的一行?
我希望你能帮忙
答案 0 :(得分:0)
我可以通过首先定义页面对象来选择行元素:
'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;
现在定义了这些页面对象,这是测试:
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();
}
);
});
});